Skip to content

Commit

Permalink
Add example of converting a list to a Capture right in arg list
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Jun 18, 2018
1 parent 036ab4c commit d1c110b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/Language/traps.pod6
Expand Up @@ -1059,8 +1059,9 @@ or L<Capture|/type/Capture> instead:
=for code :skip-test
my $list = ('b' => 2),; # this is a List containing a single Pair
foo(|$list, :$b); # okay: we passed the pair 'b' => 2 to the first argument
foo(1, |$list); # FAIL: Too many positionals passed; expected 1 argument but got 2
foo(|$list, :$b); # okay: we passed the pair 'b' => 2 to the first argument
foo(1, |$list); # FAIL: Too many positionals passed; expected 1 argument but got 2
foo(1, |$list.Capture); # OK: .Capture call converts all Pair objects to named args in a Capture
=for code :skip-test
my $cap = \('b' => 2); # a Capture with a single positional value
Expand Down

0 comments on commit d1c110b

Please sign in to comment.