Skip to content

Commit bba24ab

Browse files
committed
$start in splice defaults to 0 and can be omitted
1 parent 9a15304 commit bba24ab

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

doc/Type/Array.pod6

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,14 @@ Example:
205205
206206
Defined as:
207207
208-
multi sub splice(@list, $start, $elems?, *@replacement --> Array)
209-
multi method splice(Array:D $start, $elems?, *@replacement --> Array)
208+
multi sub splice(@list, $start = 0, $elems?, *@replacement --> Array)
209+
multi method splice(Array:D $start = 0, $elems?, *@replacement --> Array)
210210
211211
Deletes C<$elems> elements starting from index C<$start> from the C<Array>,
212212
returns them and replaces them by C<@replacement>. If C<$elems> is omitted,
213-
all the elements starting from index C<$start> are deleted.
213+
all the elements starting from index C<$start> are deleted. If both C<$start>
214+
and C<$elems> are omitted, all elements are deleted from the C<Array> and
215+
returned.
214216
215217
Each of C<$start> and C<$elems> can be specified as a
216218
L<Whatever|/type/Whatever> or as a L<Callable|/type/Callable> that returns an
@@ -222,7 +224,7 @@ argument—the number of elements in C<@list>—and its return value is used
222224
as C<$start>.
223225
224226
A C<Whatever> C<$elems> deletes from C<$start> to end of
225-
C<@list> (same as no C<$elems>). A C<Callable> C<$elements> is called with
227+
C<@list> (same as no C<$elems>). A C<Callable> C<$elems> is called with
226228
just one argument—the number of elements in C<@list> minus the value of
227229
C<$start>—and its return value is used the value of C<$elems>.
228230

0 commit comments

Comments
 (0)