In Independent routines§
See primary documentation in context for sub pop
multi pop() is raw
Calls method pop
on the Positional
argument. That method is supposed to remove and return the last element, or return a Failure
wrapping an X::Cannot::Empty
if the collection is empty.
See the documentation of the Array
method for an example.
In Array§
See primary documentation in context for method pop
method pop(Array:) 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 = <a b>; # a b.pop; # bpop ; # apop ;CATCH ;# OUTPUT: «X::Cannot::Empty: Cannot pop from an empty Array»
In role Buf§
See primary documentation in context for method pop
method pop()
Returns and removes the last element of the buffer.
my = Buf.new( 1, 1, 2, 3, 5 );say .pop(); # OUTPUT: «5»say .raku; # OUTPUT: «Buf.new(1,1,2,3)»