Tutorial by Examples

For

For-loops iterate over an iterating collection. An iterating collection is any class which structurally unifies with Iterator<T> or Iterable<T> types from the Haxe standard library. A for-loop which logs numbers in range 0 to 10 (exclusive) can be written as follows: for (i in 0...10) ...
While-loops execute a body expression as long as the loop condition evaluates to true. A while-loop which logs numbers in range 9 to 0 (inclusive) can be written as follows: var i = 10; while (i-- > 0) { trace(i); } Try the example on try.haxe.org. References "While", Ha...
Do-while-loops execute a body expression at least once, and then keep executing it as long as the loop condition evaluates to true. A do-while-loop which logs numbers in range 10 to 0 (inclusive) can be written as follows: var i = 10; do { trace(i); } while (i-- > 0); Try the example ...
The flow or execution of a loop can be controlled by use of break and continue expressions. Break break exits the current loop. In case the loop is nested inside another loop, the parent loop is unaffected. for (i in 0...10) { for (j in 0...10) { if (j == 5) break; trace(i,...

Page 1 of 1