2 ms·
Yep but the given/when is DRYer because you don't need to repeat the $grade eq re: smart match & more complicated than `eq` - Yes you can push given/when qui
by draegtun 16y ago
Yep but the given/when is DRYer because you don't need to repeat the $grade eq
re: smart match & more complicated than `eq` - Yes you can push given/when quite a bit:
given (TheTime->of_day) {
when ('morning') {
breakfast();
make_packed_lunch() if $_->is_work_day;
}
lunch() when 'afternoon';
when ('evening') {
goto_pub() if $_->is_friday;
dinner();
}
default { say "Should be sleeping if its " . $_->{dt}->ymd }
}
ref: http://stackoverflow.com/questions/3638892/what-kind-of-neat-use-cases-exist-for-given-when/3696479#3696479 http://stackoverflow.com/questions/3638892/what-kind-of-neat...