Statements
Statements control the flow of execution. Two rules hold across every kind:
- A condition is never parenthesised — write
if x > 0, notif (x > 0). - Every body is a block in braces, even when it contains a single statement.
A condition is always a bool; Rux does not treat numbers or pointers as truthy, so compare explicitly (if count != 0, not if count).
Conditionals
Loops
| Statement | Description |
|---|---|
while | Loop while a condition holds |
for / in | Iterate over a collection or range |
loop | Unconditional infinite loop |
Loop Control
| Statement | Description |
|---|---|
break / continue | Alter loop control flow |
Type Tests
The is operator tests whether a value currently holds a given type. It produces a bool: true when the value has that type, false otherwise.
if / else
if runs its block when the condition is true. Add else if to test further conditions, and a final else to handle everything that remains. The first matching block runs; the rest are skipped.