10.2.3 List
A List
is a collection for storing elements. On the surface, a list is similar to an Array. However, the underlying implementation is very different. This results in several functional differences:
- A list can not be indexed using square brackets, i.e.
[0]
. - A list can not be initialized.
- There are no list comprehensions.
- A list can freely modify/add/remove elements while iterating over them.
A simple example for working with lists:
class Main {
static public function main() {
var myList = new List<Int>();
for (ii in 0...5)
myList.add(ii);
trace(myList); //{0, 1, 2, 3, 4}
}
}
See the List API for details about the list methods.