Prev | Current Page 187 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

..myArray.length )
{
myArray[i] += ???0???;
trace( myArray[i] );
}
trace( myArray[0] );
// Outputs: item10
On running the example, the character appended to the first item should be notably permanent, or at
least until the application ends.
84
Part I: The Core Language
Iterating Over Hash Tables
The Hash and IntHash objects expose an iterator() method much like the Array and List objects.
However, only the values of the contained items are passed to the iterator. As the indexes of these objects
are accessed through the use of keys, it is not possible to use the IntIter object to directly access the
values they contain, unless the object is an IntHash with sequential key values, which really defeats
the object of these types. To get around this issue, an instance of either type provides a keys() method,
which returns an iterator containing the keys used in the collection. Once attained, the iterator can then
be used in place of the IntIter object for direct access to the collections items:
var myHash = new Hash < String > ();
myHash.


Pages:
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199