Documentation for parameter *@, assembled from the following types:
A function is variadic if it can take a varying number of arguments; that is, its arity is not fixed. Therefore, optional, named, and slurpy parameters are variadic. An array or hash parameter can be marked as slurpy by leading asterisk (*) or two leading asterisks (**) or a leading plus (+). A slurpy parameter can bind to an arbitrary number of arguments (zero or more).
These are called "slurpy" because they slurp up any remaining arguments to a function, like someone slurping up noodles.
$ = :(, ); # exactly two arguments, where the second one must be Positional$ = :(, *); # at least one argument, @b slurps up any beyond that$ = :(*); # no positional arguments, but any number of named argumentssub one-arg (@)sub slurpy (*@)one-arg (5, 6, 7); # ok, same as one-arg((5, 6, 7))slurpy (5, 6, 7); # okslurpy 5, 6, 7 ; # ok# one-arg(5, 6, 7) ; # X::TypeCheck::Argument# one-arg 5, 6, 7 ; # X::TypeCheck::Argumentsub named-names (*) ;say named-names :foo(42) :bar<baz>; # OUTPUT: «foo bar␤»
Note that positional parameters aren't allowed after slurpy parameters.
:(*, );# ===SORRY!=== Error while compiling:# Cannot put required parameter $last after variadic parameters
Normally a slurpy parameter will create an Array, create a new Scalar container for each argument, and assign the value from each argument to those Scalars. If the original argument also had an intermediary Scalar it is bypassed during this process, and is not available inside the called function.
Slurpy parameters have special behaviors when combined with some traits and modifiers, as described below.