Skip to content

Instantly share code, notes, and snippets.

@bitops
Created June 16, 2015 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitops/89bc0dde016076b5a3d1 to your computer and use it in GitHub Desktop.
Save bitops/89bc0dde016076b5a3d1 to your computer and use it in GitHub Desktop.
Simple Ruby to extract nested values from a Hash
class Hash
def extract_nested_values(hsh=self)
return hsh unless hsh.respond_to?(:keys)
hsh.keys.map do |k|
extract_nested_values(hsh[k])
end.flatten
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment