Mega Code Archive

 
Categories / Ruby / Statement
 

Raise IndexError

class MyCapacity     include Comparable     attr :volume     def initialize(volume)       @volume = volume     end     def inspect       '#' * @volume     end     def <=>(other)       self.volume <=> other.volume     end     def succ       raise(IndexError, "Volume too big") if @volume >= 9       MyCapacity.new(@volume.succ)     end   end