How to transpose Ruby Hash keys from strings to symbols
Hash[h.map {|k, v| [k.to_sym, v] }]
Read this as:
Extract each key/value pair to an array, store this list of arrays in an array then use this array to build a new Hash.
Written by Arnaud Meuret
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#