File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -276,7 +276,24 @@ variable name:
276
276
Aliases are also possible that way:
277
277
278
278
sub paint( :color(:colour($c)) ) { } # 'color' and 'colour' are both OK
279
- sub paint( :color(:$colour) ) { } # same API for the caller
279
+ sub paint( :color(:$colour) ) { } # same API for the caller
280
+
281
+ A function with named arguments can be called dynamically, dereferencing a
282
+ Pair with C < | > to turn it into a named argument.
283
+
284
+ multi f(:$named){ note &?ROUTINE.signature };
285
+ multi f(:$also-named){ note &?ROUTINE.signature };
286
+ for 'named', 'also-named' -> $n {
287
+ f(|($n => rand)) # «(:$named)(:$also-named)»
288
+ }
289
+
290
+ my $pair = :named(1);
291
+ f |$pair; # «(:$named)»
292
+
293
+ The same can be used to convert a Hash into named arguments.
294
+
295
+ my %pairs = also-named => 4;
296
+ f |%pairs; # «(:$also-named)»
280
297
281
298
= head2 Optional and Mandatory Parameters
282
299
You can’t perform that action at this time.
0 commit comments