Skip to content

Instantly share code, notes, and snippets.

@murayama
Created July 9, 2013 01:33
Show Gist options
  • Save murayama/5953961 to your computer and use it in GitHub Desktop.
Save murayama/5953961 to your computer and use it in GitHub Desktop.
rubyでハッシュのキーを再帰的にシンボルに変換する
def recursive_symbolize_keys! hash
if hash.is_a? Hash
hash.symbolize_keys!
hash.values.each {|h| recursive_symbolize_keys! h}
elsif hash.is_a? Array
hash.map {|v| recursive_symbolize_keys! v}
end
hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment