Remove the top element from the stack and return it's value If the stack is empty, return nil
()
| 34 | // Remove the top element from the stack and return it's value |
| 35 | // If the stack is empty, return nil |
| 36 | func (s *Stack) Pop() (int, error) { |
| 37 | if s.size > 0 { |
| 38 | val := s.top.value |
| 39 | s.top = s.top.next |
| 40 | s.size-- |
| 41 | return val, nil |
| 42 | } |
| 43 | return 0, errorEmptyStack |
| 44 | } |
| 45 | |
| 46 | func (s *Stack) Peek() (int, error) { |
| 47 | if s.size > 0 { |