Created
October 10, 2014 11:10
-
-
Save hannestyden/9abd77048e044ecf6b86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
alias_method :[], :fetch # !> method redefined; discarding old [] | |
end | |
h = {a: 1} | |
h[:a] # => 1 | |
h[:b] rescue $! # => #<KeyError: key not found: :b> | |
h[:b, 2] # => 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment