O
Old Echo
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
=> {
ne => 1, :two => 2, :three => 3 }
Please display your ninja skills. : )
Thanks,
kodama
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
=> {
Please display your ninja skills. : )
Thanks,
kodama