"Pe?a, Botp" <botp / delmonte-phil.com> writes:

> I would like a[1] = 6 to return array a itself, so I can do eg,
> 
> a = [1,2,3,4]
> p (a[1]=6).sort
> 
> I'm reading sir Dave's online axe book so a chapter reference would be fine.
> You could also tell me how you search it (since I've search but cannot find
> it, maybe my query is not good enough).

module MyArray
  def []=(x, y)
    super x, y
    self
  end
end

a = [1,2,3,4]
a.extend MyArray
p((a[1]=6).sort) #=> [1, 3, 4, 6]

-- 
eban