Sha256: 99af739ecddd03d572242d6216307ab262facdc1aea11697f49b29094cdd4ef0
Contents?: true
Size: 559 Bytes
Versions: 16
Compression:
Stored size: 559 Bytes
Contents
# Copied without code changes from RSpec. 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
Version data entries
16 entries across 16 versions & 4 rubygems