Control flow
Zap keeps control flow explicit. Conditions always use Bool, blocks use
braces, and loops make their iteration rule visible.
Conditions
Section titled “Conditions”Use if when a branch depends on a boolean expression.
if ready { println("start");} else { println("wait");}Repetition
Section titled “Repetition”Use while when a condition controls each iteration:
while remaining > 0 { remaining = remaining - 1;}Use for for a counted loop or iteration over an array, slice,
or collection:
for var index: Int = 0; index < 3; index = index + 1 { println(toString(index));}break leaves the nearest loop and continue starts its next iteration.
Block scope
Section titled “Block scope”Names declared inside a branch or loop are not visible after that block:
if enabled { var message = "on"; println(message);}
// `message` is not available here.Start with if when learning the individual forms.