Created
August 21, 2012 21:11
-
-
Save forforf/3419425 to your computer and use it in GitHub Desktop.
Stringify Ruby Hash - One Liner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#From Sarah Mei | |
# http://stackoverflow.com/questions/800122/best-way-to-convert-strings-to-symbols-in-hash | |
my_hash.inject({}){|memo,(k,v)| memo[k.to_s] = v; memo} | |
#To convert to symbols | |
my_hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment