Prev | Current Page 116 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

..9 )
{
numbers[a] = new Array();
for ( b = 0...9 )
{
numbers[a][b] = new Array();
for ( c = 0...9 )
{
numbers[a][b][c] = new Array();
for ( d = 0...9 )
numbers[a][b][c][d] = ( a * 1000 ) + ( b * 100 ) + ( c * 10 ) + d;
}
}
}
This should continue until you have instantiated all the Arrays in the hierarchy, though you can opt to
do this as you require them, rather than doing it all upfront. Once this is done, you can then access
the Arrays by supplying one pair of index operators per Array:
var thousands : Int = 6;
var hundreds : Int = 4;
var tens : Int = 7;
var units : Int = 3;
numbers[thousands][hundreds][tens][units] = 6473;
or:
numbers[6][4][7][3] = 6473;
Theoretically, a multidimensional Array can have as many dimensions as you like, though it is very rare
to use more than two dimensions at the time.
Lists
List s are the most lightweight of all the Array types. While they are similar to the Array type, they use
less CPU processing power and are smaller in terms of memory requirements when used with Neko.


Pages:
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128