Loops

while loop

while condition {
   body
}

Parentheses in condition are not necessary.

i = 0
while i < 5 {
  print i++
}

// or

i = 0
while (i < 5) {
  print i++
}

do-while loop

do {
   body
} while condition

Parentheses in condition are not necessary.

i = 0
do {
  print i++
} while i < 5

// or

i = 0
do {
  print i++
} while (i < 5)

for loop

for initializing, condition, increment {
   body
}

for (initializing, condition, increment) {
   body
}
for i = 0, i < 5, i++
  print i++

// or

for (i = 0, i < 5, i++) {
  print i++
}

foreach loop

Iterates elements of an string, array or map.

Iterating over string:

for char : string {
   body
}
for char, code : string {
   body
}

Iterating over array:

for value : array {
   body
}
for value, index : array {
   body
}

Iterating over map:

for key, value : map {
   body
}
for (key, value : map) {
   body
}

Parentheses are not necessary.

arr = [1, 2, 3, 4]
for v : arr {
  println v
}

map = {"key1": 1, "key2": 2}
for key, value : map
  println key + " = " value
}