Skip to content

Instantly share code, notes, and snippets.

@liwh
Created September 14, 2010 02:10
Show Gist options
  • Save liwh/578413 to your computer and use it in GitHub Desktop.
Save liwh/578413 to your computer and use it in GitHub Desktop.
class Hash
def method_missing(method, *params)
#首先得把symbol转化成string,如h={}.h.a = 1,此时,method 就为:a=
method_string = method.to_s
if method_string[-1] == 61
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