Skip to content

Instantly share code, notes, and snippets.

@fronx
Created September 5, 2011 15:58
Show Gist options
  • Select an option

  • Save fronx/1195330 to your computer and use it in GitHub Desktop.

Select an option

Save fronx/1195330 to your computer and use it in GitHub Desktop.
class Hash
def /(key)
self[key] || {}
end
end
h = {:foo => {:bar => {:baz => "BOOM"}}}
h/:foo/:bar/:baz # => "BOOM"
h/:foo/:bar/:not_existing # => nil
h/:foo/:bar/:baz/:no_hash_here # => NoMethodError: undefined method `/' for "BOOM":String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment