Sha256: 278927694e235c1d5f6ec6156be3e1fa55720b3a75abd8c89cd1edcfe885a472
Contents?: true
Size: 509 Bytes
Versions: 20
Compression:
Stored size: 509 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 top raise StackUnderflowError if @items.empty? @items.last end def empty? @items.empty? end def size @items.length end end
Version data entries
20 entries across 20 versions & 1 rubygems