repeat
loops
A repeat
loop performs an operation until it is deliberately stopped.
One may either use Escape
to halt it, or more adequately, use break
.
repeat {
expression
if {
condition
} break
}
If you attempt to run the following chunk of code using repeat
, it will display the result until you press Escape
.
repeat {
print("Press 'Esc' to stop me!")
}
[1] "Press 'Esc' to stop me!"
[1] "Press 'Esc' to stop me!"
...
...
[1] "Press 'Esc' to stop me!"