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');
12
03
01
00

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.

Course navigation

Solution: Slurpy named arguments   |   The Whatever star 🆕