File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -77,25 +77,22 @@ Defined as
77
77
sub append(\array, elems)
78
78
= end code
79
79
multi method append(Array:D: \values)
80
- multi method append(Array:D: *@values is raw)
80
+ multi method append(Array:D: ** @values is raw)
81
81
82
- Appends the argument list to the invocant (or to the first argument, in sub
83
- form). This modifies the array in-place and returns it as well.
84
- Throws for lazy arrays.
85
-
86
- The difference from L < push > is that C < append > will L < flatten|/routine/flat >
87
- all the L < Iterables|/type/Iterable > in the argument list:
82
+ Appends the argument list to the array passed as the first argument. This
83
+ modifies the array in-place. Returns the modified array. Throws for lazy arrays.
88
84
89
- my @array;
90
- my @source1 = <a b c>;
91
- my @source2 = <d e f>;
92
- my %source3 = :42a, :72b;
85
+ The difference from method C < push > is that with an array or list argument,
86
+ C < append > appends several elements (one for each array or list element),
87
+ whereas C < push > appends just one element.
93
88
94
- say @array.append: @source1; # OUTPUT: «[a b c]»
95
- say @array; # OUTPUT: «[a b c]»
89
+ Example:
96
90
97
- say @array.append: @source2, %source3; # OUTPUT: «[a b c d e f a => 42 b => 72]»
98
- say @array; # OUTPUT: «[a b c d e f a => 42 b => 72]»
91
+ my @a = <a b c>;
92
+ my @b = <d e f>;
93
+ @a.append: @b;
94
+ say @a.elems; # OUTPUT: «6»
95
+ say @a; # OUTPUT: «[a b c d e f]»
99
96
100
97
= head2 method elems
101
98
You can’t perform that action at this time.
0 commit comments