Skip to content

Instantly share code, notes, and snippets.

@murajun1978
Created May 31, 2014 13:53
Show Gist options
  • Save murajun1978/e51714dc46b66aa90585 to your computer and use it in GitHub Desktop.
Save murajun1978/e51714dc46b66aa90585 to your computer and use it in GitHub Desktop.
anonymous_class = Class.new(String) do
def hello(name)
"Hello, #{name}"
end
end
ex_class = anonymous_class.new
p ex_class.hello("murajun1978") # => murajun1978
p anonymous_class.name # => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment