From: Fergal J Byrne Date: 2007-03-16T00:47:59+09:00 Subject: Re: freeze string fails to freeze ??? jwaala.amplify@gmail.com wrote: >>> a='asdf' > => "asdf" >>> a.freeze > => "asdf" >>> a='qwer' > => "qwer" > > should'nt that throw and exception ??? > freeze is a method on the object referenced by a, not on the variable a (a is just a name, not the object itself). a = 'abcd' a.freeze # a[2]='w' raises # ./freezetest.rb:7:in `[]=': can't modify frozen string (TypeError) This causes an exception because you are trying to modify the frozen object. a = 'defg' This does not, because the object (which up to now was referenced by a) is not changed. a now refers to a different object. Try it with a constant: A = 'abcd' A = 'defg' # raises a warning: already initialized constant A -- Regards, Fergal Byrne - Technical Director Adnet: Web Builders to the Design Industry http://www.adnet.ie/ t:+353 1 855 8951 aim/skype:FergByrne === We've Moved! 63 Lower Gardiner Street, Dublin 1 ===