routine pop

Documentation for routine pop assembled from the following types:

role Buf

From Buf

(Buf) method pop

method pop()

Extracts the last element of the buffer

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

class Array

From Array

(Array) routine pop

Defined as:

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

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

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␤»