Created
October 8, 2008 15:56
-
-
Save sunny/15549 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
# irb(main):001:0> h = {} | |
# => {} | |
# irb(main):002:0> h.foo = "bar" | |
# => "bar" | |
# irb(main):003:0> h.foo | |
# => "bar" | |
class Hash | |
def method_missing(method, *params) | |
method_string = method.to_s | |
if method_string =~ /=$/ | |
self[method_string[0..-2]] = params.first | |
else | |
self[method_string] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment