Synopsis For loop.
Syntax for ( Exp1 , Exp2 , ... , Expn ) Statement;
Description The for-statement executes Statement for all possible combinations of values of the expressions Expi. If one of the expressions is a boolean expression, we do try all its possible values.

By default, the value of a for statement is the empty list. In general, the value of a for statement consists of all values contributed by Append statements that are executed during the repeated execution of its body Statement.
rascal>import IO;
rascal>for(int n <- [1 .. 5]) println("n = <n>");
n = 1
n = 2
n = 3
n = 4
list[void]: []
rascal>for(int n <- [1 .. 5]) append n * n;
list[int]: [1,4,9,16]
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit