-
Notifications
You must be signed in to change notification settings - Fork 24
Loops
Rohan Singh edited this page Aug 21, 2014
·
4 revisions
All loops support the continue
and break
statements. continue
will skip to the next iteration while break
will terminate the loop.
var i = 1;
while (i <= 10) {
print(i++);
}
var i = 1;
do {
print(i++);
} while (i <= 10);
for (var i = 1; i <= 10; i++) {
print(i);
}
foreach
loops are used to loop through sequences.
seq oneToTen() {
for (var i = 1; i <= 10; i++)
yield i;
}
foreach (var i in oneToTen()) {
print(i);
}