routine pop

Documentation for routine pop assembled from the following types:

language documentation Independent routines

From Independent routines

(Independent routines) sub pop

Defined as:

multi sub pop(@ais raw

Calls method pop on the Positional argument. That method is supposed to remove and return the last element, or return a Failure if the collection is empty.

See the documentation of the Array method for an example.

class Array

From Array

(Array) method pop

Defined as:

method pop(Array:D:is nodal

Removes and returns the last item from the array. Fails if the array is empty.

Like many Array methods, method pop may be called via the corresponding subroutine. For example:

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

role Buf

From Buf

(Buf) method pop

method pop()

Extracts the last element of the buffer

say $.pop(); # OUTPUT: «8» 
say $.raku# OUTPUT: «,1,2,3,5)»