See Original text in context
method pop()
Extracts the last element of the buffer
say .pop(); # OUTPUT: «8»say .raku; # OUTPUT: «Buf.new(1,1,2,3,5)»
See Original text in context
multi sub 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.
See Original text in context
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»