Skip to content

Commit bf0e015

Browse files
author
Jan-Olof Hendig
committed
Added docs for Map.Capture
1 parent 5f27719 commit bf0e015

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

doc/Type/Map.pod6

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,26 @@ Returns C<True> if the invocant contains at least one key/value pair.
219219
my $m = Map.new('a' => 2, 'b' => 17);
220220
say $m.Bool; # True
221221
222+
=head2 method Capture
223+
224+
Defined as:
225+
226+
method Capture(Map:D:) returns Capture:D
227+
228+
Usage:
229+
230+
MAP.Capture
231+
232+
Returns a L<Capture|/type/Capture> where each key, if any, has been converted
233+
to a named argument with the same value as it had in the original C<Map>.
234+
The returned C<Capture> will not contain any positional arguments.
235+
236+
my $map = Map.new('a' => 2, 'b' => 17);
237+
my $capture = $map.Capture;
238+
my-sub(|$capture); # 2, 17
239+
240+
sub my-sub(:$a, :$b) {
241+
say "$a, $b"
242+
}
243+
222244
=end pod

0 commit comments

Comments
 (0)