Override array method
class Array2 < Array def [](index) if index>0 super(index-1) else raise IndexError end end def []=(index,obj) if index>0 super(index-1,obj) else raise IndexError end end end x = Array2.new x[1]=5 x[2]=3 x[0]=1 # Error x[-1]=1 # Error