Sha256: 13b3931cb5f9d07ae119353d2adb950352ad2c31b666a61961bdd30ea87dcac6
Contents?: true
Size: 516 Bytes
Versions: 144
Compression:
Stored size: 516 Bytes
Contents
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
144 entries across 144 versions & 22 rubygems