Skip to content

Instantly share code, notes, and snippets.

@hakanensari
Created May 2, 2014 08:50
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 hakanensari/cb911636c326dae8a88c to your computer and use it in GitHub Desktop.
Save hakanensari/cb911636c326dae8a88c to your computer and use it in GitHub Desktop.
Hash#dig
class Hash
def dig(key)
each.find do |k, v|
return v if k == key
v.dig(key) if v.is_a?(Hash)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment