Chapter 10
Standard Library
Standard library
10.1 String.............................................
Type: String
A String is a sequence of characters.
10.2 Data Structures
10.2.1 Array.........................................
AnArrayis a collection of elements. It has one type parameter (3.2) which corresponds to the
type of these elements. Arrays can be created in three ways:
1.By using their constructor:new Array()
2.By using array declaration syntax (5.5):[1, 2, 3]
3.By using array comprehension (6.6):[for (i in 0...10) if (i % 2 == 0) i]
Arrays come with anAPIto cover most use-cases. Additionally they allow read and write
array access (5.8):
1 class Main {
2 static public function main() {
3 var a = [1, 2, 3];
4 trace(a[1]); // 2
5 a[1] = 1;
6 trace(a[1]); // 1
7 }
8 }
Since array access in Haxe is unbounded, i.e. it is guaranteed to not throw an exception, this
requires further discussion:
- If a read access is made on a non-existing index, a target-dependent value is returned.