You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conditional branching using if, else if, and else.
Parentheses: Parentheses around the conditional expression are not required.
Syntax: An if statement is followed by a block { ... } or a single instruction prefixed with a then.
if a > 0 {
} else {
}
if a > 0 then jump done // Single statement, same line, no else
Switch Statement
Value branching via switch.
Case Values: Supports literals, enum entries, sets (e.g., 3, 4, 5:), and ranges (e.g., 400..=499:, ..=-1:, 1..:).
No Fall-Through: There is no automatic fall-through between cases.
Jumping: Inside a switch, jump name targets another case, while jump #name# targets an explicit label. A jump loop between cases triggers a level 1 warning.
switch val {
1: one(), 2: two()
3, 4, 5: { b = 1; b++ }
6..=9:
b = 2
jump 3
Red: jump 3
default: jump #out#
}
Switch Expressions
Yielding values directly from a switch expression using the ? operator.
bool res = val ? { 1: true, default: false }
string yn = ok ? { "yes", "no" } // Equivalent to the ternary operator in other languages
i32 sign = value ? { ..=-1: -1, 0: 0, 1..: 1 }
Cases: Case values can be literals, enum entries, sets, and ranges (..=-1:, 1..:, 400..=499:).
Bodies: A case body can be a block, a statement on the same line (multiple cases can share a line separated by commas), or statements on the following lines up to the next case.