Skip to content

Commit 62486f3

Browse files
committed
doc Any.duckmap
1 parent 64cfe4f commit 62486f3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

doc/Type/Any.pod6

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,21 @@ For those elements C<deepmap> will descend recursively into the sublist.
171171
dd [[1,2,3],[[4,5],6,7]].deepmap(*+1);
172172
# OUTPUT«[[2, 3, 4], [[5, 6], 7, 8]]␤»
173173
174+
=head2 method duckmap
175+
176+
Defined as:
177+
178+
method duckmap(&block) is rw is nodal
179+
180+
C<duckmap> will apply C<&block> on each element and return a new list with
181+
defined return values of the block. For undefined return values, C<duckmap>
182+
will try to descend into the element if that element is inplementing
183+
C<Iterable>.
184+
185+
my @a = [1,[2,3],4];
186+
dd @a.duckmap({ $_ ~~ Int ?? $_++ !! Any });
187+
# OUTPUT«(1, (2, 3), 4)␤»
188+
174189
=head2 method flat
175190
176191
Interprets the invocant as a list, flattens it, and returns that list. Please

0 commit comments

Comments
 (0)