Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 639 Bytes

File metadata and controls

27 lines (19 loc) · 639 Bytes

Array types

Syntax
ArrayType :
   Type[ INTEGER_LITERAL ]

An array is a fixed-size sequence of N elements of type T. The array type is written as T[N]. The size is an integer literal.

Arrays are either stored in storage or memory but are never stored directly on the stack.

Examples:

contract Foo:
  # An array in storage
  bar: u8[10]

  fn do_something():
    # An array in memory
    values: u256[3] = [10, 100, 100]

All elements of arrays are always initialized, and access to an array is always bounds-checked in safe methods and operators.