Last Updated: February 25, 2016
·
1.078K
· arnaudm

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.