From: Kurt Stephens Date: 2011-06-02T09:28:25+09:00 Subject: [ruby-core:36680] Re: [Ruby 1.9 - Feature #4801][Open] Shorthand Hash Syntax for Strings On 5/30/11 9:24 AM, Michael Edgar wrote: > On May 30, 2011, at 10:19 AM, Cezary wrote: > >> Symbols are recommended in favor of Strings for hashes anyway. > > Only for fixed key sets. Symbols aren't GCd, so if the set of keys for a Hash > grows with respect to input, then forcing them all to symbols will grow your > Ruby process's memory usage irreversibly. > ... except that inline Strings have a worse performance for #==, #hash and GC churn. A String used as inline or static nmenomic in real code is pinned down anyway and will not be GCed. An inline Symbol doesn't create garbage every time it's referenced, and is guaranteed to be the same object across methods. Symbols are for nmenomics -- Strings are for sequences of characters. > Michael Edgar > adgar@carboni.ca > http://carboni.ca/ > Kurt Stephens