Skip to content

Instantly share code, notes, and snippets.

@forforf
Created August 21, 2012 21:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forforf/3419425 to your computer and use it in GitHub Desktop.
Save forforf/3419425 to your computer and use it in GitHub Desktop.
Stringify Ruby Hash - One Liner
#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