// Homework 30, challenge: package stack. Finish the TODOs. // // The rule to protect: Pop on an empty stack must not crash. It returns an // error instead. package stack import "errors" // Stack is a stack of strings. Make one with New. type Stack struct { // TODO: add a field that holds the items, with a lower case name. } // New returns an empty stack. func New() *Stack { return &Stack{} } // Push adds v on top. func (s *Stack) Push(v string) { // TODO: add v to the items. } // Pop removes and returns the top item, or returns an error if the stack is // empty. func (s *Stack) Pop() (string, error) { // TODO: check for an empty stack, then take the top item off. return "", errors.New("TODO: replace this line") } // Size returns the number of items. func (s *Stack) Size() int { // TODO: replace this placeholder value. return 0 }