List Type
Lists in Aura are a collection type that contains items of the same type. They can be instantiated like this:
The type of the list's contents is written inside a pair of square brackets, followed by a set of curly braces. In this case, the list is initialized with the values 1
, 2
, and 3
, but you can initialize an empty list, too:
All items in a list must be the same type, and must match the type specified when creating the list
Type Specification
A list's type is specified like this:
Indexing
Lists can be indexed to retrieve individual or a range of values. Index values must be integers, and are 0-based (i.e. the first item in the list is at index 0). Index values are added after the list and wrapped in square brackets, like this:
An indexing operation can also fetch a range of values from a list, which is done like this:
Methods
The Aura standard library includes a lists
module containing methods that can be called directly on list objects. As an example, to see how many items are present in a list, you would call the count
method:
These methods can also be called on list literals, like this:
To see a complete list of methods, see the standard library's lists
module