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: «,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.


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