references/sleep-functions/shift.md

GitHub

shift

Category: Arrays

Source: https://sleep.dashnine.org/manual/shift.html


Synopsis

$ shift(@array)

Removes the first element from @array and returns it.

Parameters

@array - the array to "shift" a value from.

Returns

The scalar removed from the specified array.

Side Effects / Notes

  • This function removes the first element from the specified array.

Examples

Example:

@queue = @("bottom", "middle", "top");
$bottom = shift(@queue);

println($bottom);
println("Queue is: " . @queue);

Output:

bottom
Queue is: @('middle', 'top')

See Also

&add; &pop; &push; &putAll