routine shift
1 | role Buf |
1.1 | (Buf) method shift |
2 | class Array |
2.1 | (Array) routine shift |
Documentation for routine shift
assembled from the following types:
role Buf
From Buf
(Buf) method shift
method shift()
Takes out the first element of the buffer
.shift();say .perl; # OUTPUT: «Buf.new(1,1,2,3,5,8,13,21,34,55,89)»
class Array
From Array
(Array) routine shift
Defined as:
multi sub shift(Array )multi method shift(Array:)
Removes and returns the first item from the array. Fails for an empty arrays.
Example:
my = <a b>;say .shift; # OUTPUT: «a»say .shift; # OUTPUT: «b»say .shift;CATCH ;# OUTPUT: «X::Cannot::Empty: Cannot shift from an empty Array»