From: Andrew Timberlake Date: 2009-04-09T18:48:52+09:00 Subject: Re: Hash key : string or symbol!? On Thu, Apr 9, 2009 at 11:40 AM, Abir B. wrote: > Andrew Timberlake wrote: > >>> h = {:a => :b, 2 => 4, :g=> 6 } >>> Posted via http://www.ruby-forum.com/. >>> >>> >> >> new_hash = {} >> hash.each { |k,v| new_hash[k.to_sym] = v } >> h.each { |k,v| new_hash[k.to_sym] = v } >> > > if we have nubers in the hash that we'll be converted to nil with to_sym > : Then you could use new_hash[k.kind_of?(Numeric) k : k.to_sym] = v Andrew Timberlake http://ramblingsonrails.com http://www.linkedin.com/in/andrewtimberlake "I have never let my schooling interfere with my education" - Mark Twain