docs

#E0056: 无效的索引

这个值不能被索引,或者索引不是整数。数组、列表和切片用整数索引,实现了 Index 的类型用它的键索引。

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]}");
   |            ^^^^^^^^

索引一个集合:

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

相关错误码:E0040 类型不匹配

发现错误? 在 GitHub 上编辑此页 最后更新: