haxe Loops For

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


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) {

The variable identifier i holds the individual value of elements in the iterating collection. This behaviour is similar to for-each in other languages.

A for-loop which logs elements in an array can therefore be written as follows:

for (char in ['a', 'b', 'c', 'd']) {

Try the example on try.haxe.org.


Got any haxe Question?