Skip to content

Commit b093463

Browse files
authored
Explain that List.fmt flattens
This clarifies that `List.fmt` flattens the lists it operates on; e.g., `(<a b>, <c d>)`.fmt('[%s]')` produces `[a] [b] [c] [d]`. See https://stackoverflow.com/a/69144246
1 parent 8f0dae4 commit b093463

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/Type/List.rakudoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,10 @@ say @a.sum(:wrap); # OUTPUT: «499999500000␤»
13951395
method fmt($format = '%s', $separator = ' ' --> Str:D)
13961396

13971397
Returns a string where each element in the list has been formatted according
1398-
to C<$format> and where each element is separated by C<$separator>.
1398+
to C<$format> and where each element is separated by C<$separator>. If the
1399+
list contains nested sub-lists, then C<fmt> will flatten them before
1400+
formatting each element. Thus, C<fmt> will treat C<[1, 2, [3, 4]]> as a list
1401+
with 4 elements rather than 3.
13991402

14001403
For more information about formats strings, see L<sprintf|/routine/sprintf>.
14011404

0 commit comments

Comments
 (0)