Skip to content

Instantly share code, notes, and snippets.

@takai
Created April 19, 2012 13:05
Show Gist options
  • Save takai/2420855 to your computer and use it in GitHub Desktop.
Save takai/2420855 to your computer and use it in GitHub Desktop.
class StackEmptyError < StandardError
end
class StackOverflowError < StandardError
end
class SymbolStack
def initialize
@stack = []
end
def push(obj)
raise ArgumentError unless obj.instance_of? Symbol
raise StackOverflowError if @stack.size >= 10
@stack.push(obj)
end
def pop
raise StackEmptyError if @stack.empty?
@stack.pop
end
def size
@stack.size
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment