Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
37 lines (27 sloc) 0.516 kb
class StackUnderflowError < RuntimeError
end
class StackOverflowError < RuntimeError
end
class Stack
def initialize
@items = []
end
def push object
raise StackOverflowError if @items.length == 10
@items.push object
end
def pop
raise StackUnderflowError if @items.empty?
@items.delete @items.last
end
def peek
raise StackUnderflowError if @items.empty?
@items.last
end
def empty?
@items.empty?
end
def full?
@items.length == 10
end
end
Jump to Line
Something went wrong with that request. Please try again.