From: Brian Candler Date: 2007-05-15T23:53:08+09:00 Subject: Re: Why was the "Symbol is a String"-idea dropped? On Tue, May 15, 2007 at 10:54:05PM +0900, Robert Dober wrote: > On 5/15/07, Brian Candler wrote: > > >But then what you want are not symbols, but true immutable strings. By that > >I mean: some object where I can write 10MB of binary dump. If I want to add > >one character to the end of it, then I create another object containing > >10MB+1byte of binary dump, and the old 10MB object is garbage-collected. > But of course we have immutable strings already :))) > > class IString < String > def initialize str > super(str) > freeze > end > end Yes, but it's not a singleton. It would only be of interest as a Symbol replacement if IString.new("foo") always returned the same object. You could implement this using the Multiton pattern I think. Then you could safely use IString#object_id as a method name key. Regards, Brian.