HaxeDoc2

(やまだぃちぅ) #1
The generated code may be less concise on platforms that do not support array initialization.
Essentially, such initialization code then looks like this:

1 var a = new Array();
2 a.push(1);
3 a.push(2);
4 a.push(3);


This should be considered when deciding if a function should be inlined (4.4.2) as it may inline
more code than visible in the syntax.
Advanced initialization techniques are described inArray Comprehension(Section 6.6).

5.6 Object Declaration


Object declaration begins with an opening curly brace{after whichkey:value-pairs separated
by comma,follow, and which ends in a closing curly brace}.

1 {
2 key1:value1,
3 key2:value2,
4 ...
5 keyN:valueN
6 }


Further details of object declaration are described in the section about anonymous structures
(2.5).

5.7 Field Access


Field access is expressed by using the dot.followed by the name of the field.

1 object.fieldName


This syntax is also used to access types within packages in the form ofpack.Type.
The typer ensures that an accessed field actually exist and may apply transformations de-
pending on the nature of the field. If a field access is ambiguous, understanding the resolution
order (3.7.3) may help.

5.8 Array Access.........................................


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

1 expr[indexExpr]


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


  • expris ofArrayorDynamicandindexExpris ofInt

  • expris an abstract type (2.8) which defines a matching array access (2.8.3)

Free download pdf