Control flow¶
if / else¶
The else branch is optional. Braces are always required.
for (while-style)¶
for with a condition loops until the condition is false:
This is Kod's general looping construct. There is no while keyword.
for / in (foreach)¶
Iterate over an array with for … in:
The loop variable is declared implicitly — no let needed.
break and continue¶
Works inside both loop forms:
match¶
Pattern matching on enums, integers, and strings. See Pattern matching.
match direction {
Direction.North -> print("north")
Direction.South -> print("south")
else -> print("other")
}
return¶
Return a value from a function:
A bare return (no value) is valid in -> none functions.