docs

你正在阅读 v0.1.0 的文档。Nabi 0.1.0 已不再提供支持。 最新版本:v0.1.3 →

本页尚未翻译,以下为英文原文。

#E0056: invalid indexing

The value cannot be indexed, or the index is not an integer. Index arrays, lists and slices with integers, and types that implement Index with their key.

nabi
let total = 120;
println(f"{total[0]}");
error[E0056]: cannot index into a value of type `i64`
  --> main.nabi:2:12
   |
 2 | println(f"{total[0]}");
   |            ^^^^^^^^

Index a collection:

nabi
let totals = [120, 80];
println(f"{totals[0]}");
120

Related: E0040 mismatched types

Found a mistake? Edit this page on GitHub. Last updated