This is the ThingsDB documentation for version v0, click here for the latest version!

shift

Removes the first item from a list and returns that item.

This function changes the length of the list. The shift() function works on a list type array, but not on a tuple since tuples are immutable.

This function generates an event (except when called on a variable).

Function

list.shift()

Arguments

None

Return value

The removed item from the list. A lookup_err() is raised if the list is empty.

Example

This code show an example usage of shift():

(list = [1, 2, 3]).shift();  // 1
list;

Return value in JSON format

[
    2,
    3
]