Stacks
A stack object, stack, is a LIFO (last-in-first-out) container type.
-
$stack() -> stack -
Creates a new
stackobject.
Methods
-
:clear() -
Removes all items from the stack.
-
:count() -> i64 -
Returns the number of items in the stack.
-
:is_empty() -> bool -
Returns
trueif the stack is empty. -
:peek() -> any -
Returns the item on top of the stack without removing it. Returns an
errif the stack is empty. -
:pop() -> any -
Removes and returns the item on top of the stack. Returns an
errif the stack is empty. -
:push(item: any) -
Pushes an item onto the stack.