In Control flow§
See primary documentation in context for repeat/while, repeat/until
Executes the block at least once and, if the condition allows, repeats that execution. This differs from while
/until
in that the condition is evaluated at the end of the loop, even if it appears at the front.
my = -42;repeatwhile < 5;.say; # OUTPUT: «5»repeatwhile < 5;.say; # OUTPUT: «6»repeat while < 10.say; # OUTPUT: «10»repeat while < 10.say; # OUTPUT: «11»repeatuntil >= 15;.say; # OUTPUT: «15»repeatuntil >= 15;.say; # OUTPUT: «16»repeat until >= 20.say; # OUTPUT: «20»repeat until >= 20.say; # OUTPUT: «21»
All these forms may produce a return value the same way loop
does.