Empty is considered useful
I found myself having to convert the arguments of a sub with plenty of optional named arguments into a hash to be passed on into another function.
sub f(:a?, :b?){ my %h = $a ?? a=>$a !! Emtpy, $b ?? b=>$b !! Emtpy; } dd f(b=>1); # Hash %h = {:b(1)}
As it turns out, Empty
is skipped when the list of Pairs
is turned into a Hash
. The short form of Emtpy
is |()
, a Slip
of the empty list. Unless you love Lisp, that may be a little hard to read.
Categories: Perl6
Comments (0)
Trackbacks (0)
Leave a comment
Trackback