Course of Raku / Advanced / Subroutines / Signatures
Quiz — Slurpy parameters
What does the following program print?
sub f($first, *@rest) {
say @rest.elems;
}
f('a', 'b', 'c');| 1 | 2 |
| 0 | 3 |
| 0 | 1 |
| 0 | 0 |
Fixed parameters are filled before the slurpy one.
$first takes 'a', and only the two remaining
arguments 'b' and 'c' go into
@rest, so its .elems is 2.