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.
JargonThe terms “push” and “pop” come from observing a spring-loaded stack of plates in a cafeteria. New plates are added to the stack by pushing them on top. The top-most plate is removed by “popping” it off.
$letters = ['a', 'b']
$letters.push('X')
//= ['a', 'b', 'X']
$letters.pop()
//= 'X'
print($letters)
//= ['a', 'b']