From: Dave Thomas Date: 2003-08-19T04:58:23+09:00 Subject: Re: Question: immutable strings as design goal? On Monday, August 18, 2003, at 02:44 PM, Paul Brannan wrote: > On Tue, Aug 19, 2003 at 04:06:24AM +0900, Dave Thomas wrote: >> Ruby gets around this by dup-ing strings used as Hash keys, so the >> problem doesn't crop up. > > dup-ing and freezing. It would still be possible to modify the Hash > key > if the key were not frozen. > Indeed, although there's nothing intrinsically wrong with modifying a hash key (after all, you could have arrays as hash keys, and they're not frozen). Hash#rehash (and some common sense when it comes to retaining references to keys) is your friend here. Also it might be worth mentioning that (I believe) that the keys are duped using copy-on-write semantics, so there's less overhead that some might suppose. Cheers Dave