Skip to content

Instantly share code, notes, and snippets.

@ajokela
Created April 30, 2012 15:12
Show Gist options
  • Save ajokela/2559120 to your computer and use it in GitHub Desktop.
Save ajokela/2559120 to your computer and use it in GitHub Desktop.
'dig' into a Ruby Hash
class Hash
def dig(*path)
path.inject(self) do |location, key|
location.respond_to?(:keys) ? location[key] : nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment