Skip to content

Commit 6ae8467

Browse files
committed
Adds duckmap example, closes #1720
1 parent 7194750 commit 6ae8467

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

doc/Type/Any.pod6

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,16 @@ Defined as:
215215
216216
C<duckmap> will apply C<&block> on each element that behaves in such a way that
217217
C<&block> can be applied. If it fails, it will descend recursively if possible,
218-
or otherwise return the item without any transformation.
218+
or otherwise return the item without any transformation. It will act on
219+
values if the object is C<Associative>.
219220
220-
<a b c d e f g>.duckmap(-> $_ where <c d e>.any { .uc }).say;
221-
# OUTPUT: «(a b C D E f g)␤»
222-
(('d', 'e'), 'f').duckmap(-> $_ where <e f>.any { .uc }).say;
223-
# OUTPUT: «((d E) F)␤»
221+
=for code
222+
<a b c d e f g>.duckmap(-> $_ where <c d e>.any { .uc }).say;
223+
# OUTPUT: «(a b C D E f g)␤»
224+
(('d', 'e'), 'f').duckmap(-> $_ where <e f>.any { .uc }).say;
225+
# OUTPUT: «((d E) F)␤»
226+
{ first => ('d', 'e'), second => 'f'}.duckmap(-> $_ where <e f>.any { .uc }).say;
227+
# OUTPUT: «{first => (d E), second => F}␤»
224228
225229
In the first case, it is applied to C<c>, C<d> and C<e> which are the ones that
226230
meet the conditions for the block (C<{ .uc }>) to be applied; the rest are

0 commit comments

Comments
 (0)