Labeled loops
Nested loops can of couse contain labels,
which will make it easier to break inner cycles.
There are two ways of specifying labels when using last
,
next
and redo
: either traditional syntax like next LABEL
:
START: for 1..5 -> $n { for 'a'..'e' -> $c { next START if $n == $c.ord - 'a'.ord; say $n, $c; } }
or object-oriented one: LABEL.next
.
START: for 1..5 -> $n { for 'a'..'e' -> $c { START.next if $n == $c.ord - 'a'.ord; say $n, $c; } }