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

List.push

push($item)

Description

Add an item to the end of a List.

This function is the opposite of pop.

To add an element elsewhere in a List, use insert.

RememberThe terms “push” and “pop” come from a spring-loaded stack of plates in a cafeteria. The top-most plate is “popped” off, and new plates are “pushed” onto the stack.

$letters = ['a', 'b'];

$letters.push('X');
//= ['a', 'b', 'X']

$letters.pop();
//= 'X'

print($letters);
//= ['a', 'b']

See Also