Control flow
If, elif, else
func if_test(i32 val):void {
if(val == 1) {
trace 1
} elif(val == 2) {
trace 2
} else {
trace "I dont know"
}
}
Conditions are wrapped in parentheses. elif is used for additional branches rather than else if.
While loop
For loop
The loop variable is declared inline with a full type declaration. The variable must be mut since the loop increments it.
Switch
func switch_test(i32 val):void {
switch(val) {
case 1:
trace 1
case 2:
trace 2
default:
trace "No Num"
}
}
Unlike C, the compiler always breaks after each case. Fallthrough is not possible as each case is isolated by design.