Everything is a reference?

This confuses me:

irb(main):001:0> h = {}
=> {}
irb(main):002:0> t = [ 1, 2, 3]
=> [1, 2, 3]
irb(main):003:0> h[“f”] = t
=> [1, 2, 3]
irb(main):004:0> t += [ 4, 5, 6 ]
=> [1, 2, 3, 4, 5, 6]
irb(main):005:0> t
=> [1, 2, 3, 4, 5, 6]
irb(main):006:0> h[“f”]
=> [1, 2, 3]
irb(main):007:0>

I thought h[“f”] held a reference to the object t so if t changed, so
would h[“f”].

I’m using Ruby 2.0.0p247 (Also tested on 1.8.7 so obviously I’ve been
confused the whole time.)

What confuses me is this implies that the assignment of h[“f”] is making
a copy of t at the time of the assignment.

I think I see now. The += is not an operator.

From the Pick Axe book:

In common with other languages, Ruby has a syntactic shortcut: a = a + 2
may be written as a += 2. The second form is converted internally to the
first.

So, when I do t += [ 4, 5, 6] I’m creating a new object and pointing t
to it.

Thanks,
Perry