Hi,

try this:

class Foo
  attr_accessor :reference
  def initialize()
    @reference = []
  end
  def a=(value)
    @reference[0] = value
  end
  def a
    @reference[0]
  end
  def b=(value)
    @reference[1] = value
  end
  def b
    @reference[1]
  end
end

foo = Foo.new
foo.a = 42
p foo.reference[0]
foo.reference[1] = 3
p foo.b
foo.reference = ["Hello", "world"]
p foo.a

__END__

Output is:

42
3
"Hello"

You might also want to revise classes, attributes, attr_accessor
(along with attr_reader and attr_writer) and initialize.

Regards,

Sean