Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 786 Bytes

5.8.数组访问.md

File metadata and controls

19 lines (12 loc) · 786 Bytes

5.8.数组访问

数组访问通过使用开口的 [ 方括号,后跟索引表达式 ,并以闭口的方括号 ]结束。

Array access is expressed by using an opening bracket [ followed by the index expression and a closing bracket ].

expr[indexExpr] 

这个符号允许使用任意表达式,但是在类型级别,只有某个组合被承认:

This notation is allowed with arbitrary expressions, but at typing level only certain combinations are admitted:

  • expr 是Array或者 Dynamic 类型,indexExpr是Int类型
  • expr是一个抽象类型(第2.8节),定义要给匹配的数组访问(第2.8.3节)
  • expr is of Array or Dynamic and indexExpr is of Int
  • expr is an abstract type (2.8) which defines a matching array access (2.8.3)