- or download this
given($data) {
when (1) { say 'one' ; }; ## no "break" needed
when (2) { say 'two' ; };
default { say 'something else'; };
}
- or download this
# this code does not work !
# it will say "something else"
...
when (2) { say 'one or two' ; };
default { say 'something else'; };
}
- or download this
# this works, is shorter and easier to read
given($data) {
when ([ 1, 2]) { say 'one or two' ; };
default { say 'something else'; };
}