From: Austin Ziegler Date: 2006-06-01T04:47:02+09:00 Subject: Re: Constant Hash strangeness On 5/31/06, Wiktor Macura wrote: > Hello. > > This seems to be trivial, yet I can't find an explanation for it > anywhere online. Apologies if I'm asking the obvious. > > If you create a constant hash: > > CONSTANTHASH = { :foo => "foobar" } > x = CONSTANTHASH[:foo] > x << "-suffix" > p CONSTANTHASH > > One gets the following output: > > { :foo => "foobar-suffix" } > nil > > So, this sort of makes sense if one considers that variables in Ruby > are references. So Ruby only protects the hash, not the values keys in > the hash point to. But... is there any way to protect the values, and > not just the keys? Constants don't work the way that you think they do. I'll be posting an article about this soon; I just haven't decided where to put it. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca