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

List.popFirst

popFirst() -> any

Description

This function is like pop, but it removes and returns the first item in a List.

This function is the opposite of pushFirst.

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.pushFirst('X')
//= ['X', 'a', 'b']

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

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

[].popFirst()
//= ''

See Also