Call a function: Difference between revisions

→‎{{header|Perl 6}}: mention arglist interpolation via |
(→‎{{header|Perl 6}}: optional args don't look any different from required args)
(→‎{{header|Perl 6}}: mention arglist interpolation via |)
Line 174:
on whether a signature accepts a list at that position in the argument list, but
describing that is not the purpose of this task. Suffice to say that we assume here that the
foo function is declared with a signature of the form (*@params). The calls above might be interpreted as having a single array argument if the signature indicates a normal parameter instead of a variadic one. What you cannot do in Perl 6 (unlike Perl 5) is pass an array as several fixed arguments. By default it must either represent a single argument, or be part of a variadic list. You can force the extra level of argument list interpolation using a prefix <tt>|</tt> however:
 
<lang perl6>my @args = 1,2,3;
foo(|@args); # equivalent to foo(1,2,3)</lang>
 
Calling a function with named arguments:
Anonymous user