Combined from primary sources listed below.
See primary docmentation in context for sub pop.
multi pop(@a) 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 primary docmentation in context for method pop.
method pop()
Returns and removes the last element of the buffer.
my $bú = Buf.new( 1, 1, 2, 3, 5 );
say $bú.pop(); # OUTPUT: «5»
say $bú.raku; # OUTPUT: «Buf.new(1,1,2,3)»
See primary docmentation in context for method pop.
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»