Version: v0.7.0 - Beta.  We welcome contributors & feedback.

List.insertAll

insertAll($index, $otherList) -> self

Description

Insert multiple items into a List, staring at $index.

This will bump all items to the right that are currently at that index or higher (adding to their index.)

If $index is negative, it counts from the end of the list (the last item is at -1).

To add the items to the end of the List, use pushAll.

$list1 = ['a', 'b']
$list2 = ['X', 'Y']

$list1.insertAll(1, $list2)
//= ['X', 'Y', 'a', 'b']

$list1.insertAll(-1, $list2)
//= ['a', 'X', 'Y', 'b']

See Also