Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!

List.remove

remove($index, $numItems = 1)

Description

Remove an element starting at $index and return its value.

If $index is negative, it counts from the end.

This function is the opposite of $insert.

$items = ['a', 'b', 'c', 'd', 'e'];

$items.remove(0);
//= 'a'

print($items);
//= ['b', 'c', 'd', 'e']

$items.remove(-2);
//= 'd'

print($items);
//= ['b', 'c', 'e']

Multiple Items 

If numItems is more than 1, the values will be returned as a List.

$items = ['a', 'b', 'c', 'd', 'e'];

// Remove the first 2 items
$items.remove(0, 2);
//= ['a', 'b']

print($items);
//= ['c', 'd', 'e']

See Also