Pop is return last value that insert into our stack also it will remove it in our stack
()
| 36 | // Pop is return last value that insert into our stack |
| 37 | // also it will remove it in our stack |
| 38 | func (sl *SList) Pop() (any, error) { |
| 39 | if !sl.IsEmpty() { |
| 40 | // get last element that insert into stack |
| 41 | element := sl.Stack.Front() |
| 42 | // remove element in stack |
| 43 | sl.Stack.Remove(element) |
| 44 | // return element value |
| 45 | return element.Value, nil |
| 46 | } |
| 47 | return "", fmt.Errorf("stack list is empty") |
| 48 | } |
| 49 | |
| 50 | // Length return length of our stack |
| 51 | func (sl *SList) Length() int { |