Continue

The continue statement can be used inside a given/when construct to continue to the next branch.

given (10) { |i|
    when (10) {
        say "It's ten"
        continue
    }
    case (i.is_even) {
        say "It's even"
        continue
    }
    case (i % 5 == 0) {
        say "It's divisible by 5"
    }
}

Output:

It's ten
It's even
It's divisible by 5

Last updated