routine shift

Documentation for routine shift assembled from the following types:

class Array

From Array

(Array) routine shift

Defined as:

multi sub    shift(Array:D )
multi method shift(Array:D:)

Removes and returns the first item from the array. Fails for an empty arrays.


my @foo = <a b>;
say @foo.shift;             # OUTPUT: «a␤» 
say @foo.shift;             # OUTPUT: «b␤» 
say @foo.shift;
CATCH { default { put .^name''.Str } };
# OUTPUT: «X::Cannot::Empty: Cannot shift from an empty Array␤» 

role Buf

From Buf

(Buf) method shift

method shift()

Takes out the first element of the buffer

    say $.perl# OUTPUT: «,1,2,3,5,8,13,21,34,55,89)»