Skip to content

Instantly share code, notes, and snippets.

@idlefingers
Created January 5, 2014 17:38
Show Gist options
  • Save idlefingers/8271296 to your computer and use it in GitHub Desktop.
Save idlefingers/8271296 to your computer and use it in GitHub Desktop.
class Hash
def has_nested_keys?(*args)
args.inject(self) do |hash,key|
hash.fetch key, nil
end
end
end
hash = {a: {b: {c: 1}}}
hash.has_nested_keys? :a, :b, :c # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment