On Sat, Sep 3, 2011 at 6:31 PM, jack jones <shehio_22 / hotmail.com> 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?