Skip to content

Instantly share code, notes, and snippets.

/(pry) Secret

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