docs

您正在閱讀 v0.1.2 的文件。Nabi 0.1.2 已停止支援。 最新版本: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