Prev | Current Page 121 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

One might consider a Hash to resemble more closely
that of an object in JavaScript and Actionscript, with the added benefit that one can iterate through each
of the values stored in a Hash .
Chapter 3: Learning the Basics
49
Table 3-5
Hash Method Description
exists( key : String ) : Bool Returns true if a value exists for a given key
get( key : String ) : T Returns the value for a given key
iterator() : Iterator Returns an iterator of the item values in the
Hash or IntHash
keys() : Iterator Returns an iterator of the item keys in the Hash
or IntHash
remove( key : String ) : T Removes an item specified by the given key
set( key : String, value : T) : Void Sets the value of a given key
toString() : String Returns a string representation of the Hash or
IntHash
Table 3 - 5 defines the methods provided by the Hash and IntHash classes.
Adding, Querying, and Removing Items from a Hash
The methods in a Hash type are not extensive. Unlike the Array, you are not offered countless methods
for every possible undertaking you could possibly imagine.


Pages:
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133