> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/s/stack.md).

# Stack

Using a built-in array:

```ruby
var stack = []
stack.push(42)          # pushing
say stack.pop           # popping
say stack.is_empty      # is_emtpy?
```

Creating a Stack class:

```ruby
class Stack(stack=[]) {
    method pop        { stack.pop }
    method push(item) { stack.push(item) }
    method empty      { stack.is_empty }
}
 
var stack = Stack()
stack.push(42)
say stack.pop           # => 42
say stack.empty         # => true
```
