Control flow
Conditionals
if condition { ... } runs its block when the condition evaluates to
true. If the condition is false, Oryn runs the optional else block
or continues after the statement. The condition must be a boolean.
score := 42;
if score >= 40 {
print("Passed");
} else {
print("Try again");
}
This file prints Passed. At file scope, a return inside a block exits the
file. Bindings declared inside the block are visible only within that block
and its nested blocks. A binding name must be distinct from any name already
in scope.
While loops
while condition { ... } checks a boolean condition before each iteration.
It runs the body while the condition is true and continues after the loop
as soon as it is false. If it starts out false, the body never runs.
n :~ 1;
sum :~ 0;
while n <= 100 {
sum = sum + n;
n = n + 1;
}
print(sum);
This file prints 5050. Bindings declared in the body are local to that
iteration. Assignments to mutable bindings in an enclosing scope persist
into the next iteration.