# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/stacks-and-queues-in-verse
# Local doc: epic-docs/documentation/en-us/fortnite/stacks-and-queues-in-verse.md
# Section: Push and Pop
# Adds NewElement to the top of the stack by returning a new
# stack with NewElement as the top
Push<public>(NewElement:t):stack(t)=
stack(t){Elements := Elements + array{NewElement}}
# Removes the element on top of the stack and returns a tuple of both a new
# stack with the top element removed and the removed element.
Pop<public>()<decides><transacts>:tuple(stack(t),t)=
FirstElement := Peek[]
(stack(t){Elements := Elements.RemoveElement[Elements.Length - 1]}, FirstElement)
Verse Library
verse
04 Push And Pop
Implements push and pop operations for a stack data structure, managing element addition and removal.
extracted-snippets/documentation/en-us/fortnite/stacks-and-queues-in-verse/04-push-and-pop.verse