Prev | Current Page 183 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The for loop checks that the iterator object has values to iterate by making a call to the iterator ??™ s
hasNext() method. This method evaluates whether min is less than max ( min < max ) and
returns the result of this expression. If it returns true , then there is at least one value to iterate,
otherwise the for loop exits.
2. The in keyword assigns the return value of the iterator ??™ s next() method to the variable
provided on the left - hand side of the in keyword. This assignment is performed in the same
way as the expression myInt = min , which means that, if the value to assign is not an object,
then a copy is assigned, otherwise a reference is assigned. In the case of an IntIter , an Int is
always assigned.
3. After the value of min is assigned, it is incremented by 1 ready for the next loop. Once the code
supplied to the for loop has been executed, the process repeats from step 1.
As the value of min is evaluated as being less than max , the range of numbers supplied in the loop will
never be equal to the max variables value.


Pages:
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195