Skip to content

Instantly share code, notes, and snippets.

/(pry) Secret

Created December 6, 2012 19:03
Show Gist options
  • Save anonymous/6c8f0c1f0dffaef00602 to your computer and use it in GitHub Desktop.
Save anonymous/6c8f0c1f0dffaef00602 to your computer and use it in GitHub Desktop.
def flatten_hash(hash)
hash.map do |k, v|
if v.is_a?(Hash)
[k, *flatten_hash(v)]
else
[k, v]
end
end.flatten
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment