Skip to content

Instantly share code, notes, and snippets.

@sunny
Created October 8, 2008 15:56
Show Gist options
  • Save sunny/15549 to your computer and use it in GitHub Desktop.
Save sunny/15549 to your computer and use it in GitHub Desktop.
# 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