From: "s.ross" Date: 2008-01-02T08:45:33+09:00 Subject: Re: transform hash key from string into symbol class Hash def super_cool_hash_key_string_to_sym_transformation self.each_key{|k| k = k.to_sym} self end end -or- my_hash.each_key{|k| k = k.to_sym} Either of these work for you? On Jan 1, 2008, at 3:26 PM, Old Echo wrote: > Hello Rubyists, > When dealing with hashes, I like using symbols for key names instead > of > strings. Is there an easy way to convert hash keys from symbols into > strings? > > E.g. I'd like to do something like this: > > my_hash = YAML.load_file('my_file.yml') > => { 'one' => 1, 'two' => 2, 'three' => 3 } > my_hash.super_cool_hash_key_string_to_sym_transformation #one line of > code? > ... > my_hash > => { :one => 1, :two => 2, :three => 3 } > > Please display your ninja skills. : ) > > Thanks, > kodama > -- > Posted via http://www.ruby-forum.com/. >