Repeat Loops
Repeat loops in Claro enable you to easily repeat a task some number of times:
Fig 1:
repeat (5) {
print("Repeating...");
}
Output:
Repeating...
Repeating...
Repeating...
Repeating...
Repeating...
The loop count can be computed at runtime:
Fig 2:
var loopCount = random::nextNonNegativeBoundedInt(random::create(), 10);
repeat (loopCount) {
print("Repeating...");
}
Output:
Repeating...
Repeating...