Documentation for method duckmap

Documentation for method duckmap, assembled from the following types:

class Any

From Any

(Any) method duckmap

Defined as:

method duckmap(&blockis rw is nodal

duckmap will apply &block on each element and return a new list with defined return values of the block. For undefined return values, duckmap will try to descend into the element if that element implements Iterable.

my @a = [1,[2,3],4];
dd @a.duckmap({ $_ ~~ Int ?? $_++ !! Any });
# OUTPUT: «(1, (2, 3), 4)␤»