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

List.pop

pop() -> any

Description

Remove and return the last item in a List.

This function is the opposite of push.

If there are no items in the List, it returns the default value of the list (e.g. an empty string).

To remove an item elsewhere in a List, use remove.

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

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

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

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

See Also