For loop

The for in construct can be used to iterate through an iterator. It can be used to iterate over a range type.

// Iterate from 0 (inclusive) to 101 (exclusive) [0; 101[
for i in 0 .. 101 { 
    if i % 2 == 0 {
        println ("even");
    } else {
        println ("odd");
    }
}

It can also iterate over arrays.

let a = [1, 2, 3];    
for it in [3, 2, 1] {
    println (it); // 3, 2, 1
}
// The iterator is a reference 
for it in a {
    it = it + 1;
}
println (a); // [2, 3, 4]