in reply to Spotting an empty array as argument
The only flexible workaround I found using prototypes is a (;&) , which will mean you need to put your parameters in a block.
Not sure if you are willing to pay that price of surrounding your parameters in curlies, but a block can hold any number and type of list elements.
DB<32> sub my_say (;&) { $_[0] ? say $_[0]->() : say $_ } DB<33> @a=('a1'..'a3'); $a="A",$b="B"; $_=666 DB<34> my_say 666 DB<35> my_say {@a} a1a2a3 DB<36> my_say {@a,$a} a1a2a3A DB<37> my_say {$a,1..3} A123 DB<38>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Spotting an empty array as argument
by Chuma (Scribe) on Mar 25, 2021 at 22:09 UTC |