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
$bú.shift(); say $bú.raku; # 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:D ) multi method shift(Array:D:)
Removes and returns the first item from the array. Fails for an empty arrays.
Example:
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»