Sebastian Hungerecker
8/28/2008 10:09:00 AM
Mischa Fierer wrote:
> The number, as I would expect, stays at two, but the hash is actually
> changed by the method, as if I were passing it a pointer in C or
> something...
Well, that's exactly what's happening at C level - in both cases. The
difference is that if you do foo[bar] = baz or foo.method_that_changes_foo!
then you change the object that foo points to (so all other variables that
point to the same object will also reflect those changes), but if you do
foo = bar, you're just changing the pointer, i.e. foo now points to wherever
bar points to and the object that it previously pointed to is unchanged.
HTH,
Sebastian
--
Jabber: sepp2k@jabber.org
ICQ: 205544826