From: "Jesús Gabriel y Galán" Date: 2010-11-05T17:43:44+09:00 Subject: Re: the second argument On Fri, Nov 5, 2010 at 9:10 AM, wroxdb wrote: > Hello, > > what's the argument of "obj" in:   def []=(index,obj) ? > > I don't see it call this method with the second argument. > Thanks > > > The original code is: > > 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 This is syntactic sugar for x.[]=(1,5) which is the method you are asking about. > x[2]=3 > x[0]=1 # Error > x[-1]=1 # Error Jesus.