Skip to content

Instantly share code, notes, and snippets.

@lian
Created December 14, 2011 11:11
Show Gist options
  • Save lian/1476162 to your computer and use it in GitHub Desktop.
Save lian/1476162 to your computer and use it in GitHub Desktop.
class Hash
alias get []
def [](*a)
a.size == 1 ? get(*a) : (self[a.shift][*a] rescue nil)
end
end
p( {}[:a, :b] )
p( {:a => {:b => "c"}}[:a, :b] )
p( {:a => {:b => "c"}}[:a, :b, :c] )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment