From: matu Date: 2008-07-27T23:44:46+09:00 Subject: Re: "nested" methods Stefan Buhr wrote: > Hi there, > > I want to do this: > > @myclass.items[5] = an_item > > But the items object of @myclass should have an custom setter. I have > tried this: > class Myclass > def items > def []= value > -code- > end > end > end > > but this does not work. How can i do that? > class MyArray < Array def []= index, value super p 'hi' end end class Myclass attr_accessor :items end m = Myclass.new m.items = MyArray.new m.items[5] = "blah"