Skip to content

Instantly share code, notes, and snippets.

@scytacki
Created April 20, 2012 17:43
Show Gist options
  • Save scytacki/2430594 to your computer and use it in GitHub Desktop.
Save scytacki/2430594 to your computer and use it in GitHub Desktop.
class Hash
def method_missing(m,*a)
if m.to_s =~ /=$/
self[$`] = a[0]
elsif a.empty?
self[m]
else
raise NoMethodError, "#{m}"
end
end
end
x = {'abc' => 123}
x.foo = :baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment