Control flow
For a:Boolean
and b:Boolean
, conditionals can be written as follows:
if a {
// do something
} else if b {
// do something
} else {
// do something
}
else if
blocks may appear, and zero or one else
block.
Tip
Parentheses around the conditions are optional, i.e. if you can write if a { ... }
or if (a) { ... }
. The same applies to the loop structures below.
Conditional loops are written as:
while a {
// do something
}
do {
// do something
} while a;
for a in b..c {
// do something
}
a
will be declared as a new variable of Integer
type, and b
and c
evaluate to Integer
type, with b <= c
.
Tip
It is not possible to iterate backward simply by setting b > c
.