From: Josh Cheek Date: 2011-09-04T08:43:30+09:00 Subject: Re: arrays(setters and getters) --f46d043c7d987b7f4a04ac120b99 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Sep 3, 2011 at 6:31 PM, jack jones wrote: > Isn't there any other way to invoke shehio.array[index] = sth ... Can > this be achieved? > > -- > Posted via http://www.ruby-forum.com/. > > Yes, but not from instances of Whatever. You can fake out the object you return from the array method class Whatever # this class does nothing that real arrays don't already do, so... class FakeArray def initialize @real_array = ["apple", "banana", "peach"] end def []=(index, val) @real_array[index] = val end def [](index) @real_array end end attr_accessor :array def initialize @array = FakeArray.new end end What are you trying to do that you think you need this capability? --f46d043c7d987b7f4a04ac120b99--