Skip to content

Instantly share code, notes, and snippets.

@dugger
Created October 2, 2015 18:53
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 dugger/9314033daa2d6b4368a0 to your computer and use it in GitHub Desktop.
Save dugger/9314033daa2d6b4368a0 to your computer and use it in GitHub Desktop.
Lets create a hash that can handle missing keys (treat them as nil)! πŸ˜‰
class MyHash < Hash
def []=(key=nil, value)
super(key,value)
end
def [](key=nil)
super(key)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment