Perl 6 Perl 6 today #42

Subroutines, slurpy params

For subs with a variable number of arguments, use slurpy parameters, indicated by a leading asterisk:

sub say_double(*@numbers) {
    for @numbers {
        say 2 * $_;
    }
}

say_double();           # No output
say_double(21);         # 42\n
say_double(5,7,9);      # 10\n14\n18

For more, see Synopsis 6

Copyright © 2009
http://www.pmichaud.com/2009/pres/