You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<seatek> Hello :) So, wondering if anyone might know - in a parameter
signature, if you have a slurpy array (*@thing) -- is there a way to
define a default set of values for it, if nothing gets slurped up?
<seatek> sub MAIN ( Str :$log-file = 'blah', Bool :$thing = False,
@srcDirs = ('/tmp', '/var/log' ))
<seatek> that would give the error
<seatek> Cannot put optional positional parameter @srcDirs after
variadic parameters
<seatek> and if you give it the slurpy splat, it's the same error message
<masak> seatek: I agree that "it's the same error message" is more
confusing than it has to be
<masak> m: sub MAIN (:$named, *@srcDirs = ("/tmp", "/var/log" )) {}
<camelia> rakudo-moar 83d733: OUTPUT«===SORRY!=== Error while
compiling <tmp>Cannot put optional positional parameter @srcDirs
after variadic parameters [...]
<masak> seatek: what it really should do in the case of the slurpy is
to give you the error "Cannot put default on slurpy parameter
@srcDirs"
<masak> m: sub MAIN (*@srcDirs = ("/tmp", "/var/log" )) {}
21:07 <+camelia> rakudo-moar 83d733: OUTPUT«===SORRY!=== Error while
compiling <tmp>Cannot put default on slurpy parameter @srcDirs [...]
<masak> ...which it does if you don't put named parameters before it
<masak> seatek: I think as to your original question -- whether it's
supported -- the answer is no because you basically can not *not* pass
in a set of values to the slurpy parameter.
<seatek> masak: yeah, that makes complete sense when you really think about it
Migrated from rt.perl.org#129768 (status was 'new')
Searchable as RT129768$
The text was updated successfully, but these errors were encountered: