File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -453,12 +453,21 @@ L<Pair|/type/Pair> with C<|> to turn it into a named argument.
453
453
my $pair = :named(1);
454
454
f |$pair; # «(:$named)»
455
455
456
- The same can be used to convert a Hash into named arguments.
456
+ The same can be used to convert a C < Hash > into named arguments.
457
457
458
458
my %pairs = also-named => 4;
459
459
sub f(|c) {};
460
460
f |%pairs; # «(:$also-named)»
461
461
462
+ A C < Hash > that contains a list may prove problematic when slipped into named
463
+ arguments. To avoid the extra layer of containers coerce to L < Map|/type/Map >
464
+ before slipping.
465
+
466
+ class C { has $.x; has $.y; has @.z };
467
+ my %h = <x y z> Z=> (5, 20, [1,2]);
468
+ say C.new(|%h.Map);
469
+ # OUTPUT « C.new(x => 5, y => 20, z => [1, 2]) »
470
+
462
471
X < |optional argument (Signature) >
463
472
= head2 Optional and Mandatory Parameters
464
473
You can’t perform that action at this time.
0 commit comments