From: Robert Dober Date: 2008-02-12T06:01:34+09:00 Subject: Re: Hash keys On Feb 11, 2008 9:51 PM, Rick DeNatale wrote: > On 2/11/08, J. Cooper wrote: > > I ran into something I hadn't realized (common occurrence). Keying a > > hash with a symbol is not the same as using a string. I guess it makes > > sense, but I've seen it done both ways, and I had been always using > > symbols for my keys. But then I ran into an issue on loading an external > > YAML object into a hash, and didn't realize it was keyed with strings so > > I got errors the first time around. > > > > So two questions: > > 1) What is the preferred method of keying hashes? Symbols, strings, > > other? > > Symbol keys > + :a is one less keystroke than "a" > +? performance of Hash with symbol keys MIGHT be slightly > faster, but probably insignificant. > - More symbols get interned which can't get garbage > collected, even after the hash is. Hmm very interesting but is this not rather an implementation choice? Which does not make the information less valuable of course, just curious? Cheers Robert