The hasNext() method takes no arguments and will return true if it has more
objects to iterate over and false if it doesn ??™ t. The next() method also takes no arguments and returns the
next object in the iterators stack.
Anyway, many of the types and processes in haXe that make use of iterators will automatically access
the hasNext() and next() methods of an iterator. The for loop is one of these.
The IntIter Object
As it has been said before, IntIter is the most basic available iterator and is the most commonly used in
haXe applications, as it aids in iterating from one given value of type Int to another given value of type
Int . You can use the IntIter object by first instantiating it as you would an Array while supplying it
with your minimum and maximum values, which are assigned to hidden variables labeled min and max
respectively. You then pass a variable identifier and the instanced object to the for loop for iteration and
separate them with the in keyword, like this:
var iter = new IntIter(0,10);
for ( i in iter )
trace ( i );
82
Part I: The Core Language
When the loop is run, the following procedure is carried out:
1.
Pages:
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194