Skip to content

Commit 3a46a12

Browse files
committed
List.pod: Fix .push examples to use .append instead
1 parent 52a3976 commit 3a46a12

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

doc/Type/List.pod

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,18 @@ inside a scalar as a single element, as long as it's part of another .
3030
3131
Lists generally don't interpolate (flatten) into other lists, except
3232
when they are not itemized, and the single argument to an operation
33-
such as C<push>:
33+
such as C<append>:
3434
3535
my @a = 1, 2, 3;
3636
my @nested = @a, @a; # two elements
3737
my @flat = flat @a, @a; # six elements, with explict flat
3838
my @b = 'a', 'b';
39-
@b.push: @a; # @b now has 5 elements, because @a
40-
# is the sole argument to push
39+
@b.append: @a; # @b now has 5 elements, because @a
40+
# is the sole argument to append
4141
my @c = 'a', 'b';
42-
@c.push: @a, ; # @b now has 3 elements, because of the
43-
# trailing comma
44-
my @c = 'a', 'b';
45-
@c.push: $@a; # @b now has 3 arguments, because @a was
46-
# itemized
42+
@c.append: $@a; # @b now has 3 elements, because of the
43+
# itemization with $
44+
say @c.elems;
4745
4846
C<.item> can often be written as C<$( ... )>, and on an array variable
4947
even as C<$@a>.
@@ -56,7 +54,7 @@ L<Iterable|/type/Iterable> role, notable L<hashes|/type/Hash>:
5654
my @c = %h, ; say @c.elems; # 1
5755
my @d = $%h; say @d.elems; # 1
5856
59-
Slurpy parameters (C<*@a>) flattens non-itemized sublists:
57+
Slurpy parameters (C<*@a>) flatten non-itemized sublists:
6058
6159
sub fe(*@flat) { @flat.elems }
6260
say fe(<a b>, <d e>); # 4

0 commit comments

Comments
 (0)