Bounded loops allow you to execute a set of statements a number of times which is known before entering the loop. The number of times might be determined by a range or a collection.
for <id> in <rangeStart>..<rangeEnd> do
<statements>
end
for i in 1..3 do
display i
end
for <id> in <expression> do
<statements>
end
ages as Int[String]
ages = ["John" : 23, "Peter" : 42, "Mary" : 29]
for name in ages do
display name
end
for each <id> in <expression> [where <condition>] do
<statements>
end
ages as Int[String]
ages = ["John" : 23, "Peter" : 42, "Mary" : 29]
for each age in ages do
display age
end
ages as Int[String]
ages = ["John" : 23, "Peter" : 42, "Mary" : 29]
for each age in ages
where age > 25
do
display age
end
Loop execution can be stopped by using an Exit Statement. Execution will continue from the first statement following the end of the loop.