Control Structures
If Expression
Resolves a conditional expression and executes a block if the expression resolves to true
; otherwise executes an optional else block.
Like blocks, the last value resolved by an if expression is passed to the parent expression.
If the if expression lacks an else
statement, the expression passes none
on false.
if text == "" {
# do something
}
value: if EXPR {
true
} else {
false
}
Control structures may be appended as else branches.
if x < 0 {
# do something
} else if x > 0 {
# do something
} else {
# do something
}
While Expression
(future) Resolves a conditional expression and repeatedly executes a block so long as the conditional resolves to true
.
while EXPR {
}
Like if expressions, while expressions may have else branches, which execute if the condition resolves to false
.
Notably, the else expression is not executed on interrupts such as break
.
while EXPR {
# do something
if EXPR { break }
} else {
# do something
}
For Expression
(future) Assigns a variable and executes a block for each element in an iterative object.
for i : [0, 1, 2, 3] {
print i
}