问题
Example
def Object.const_missing(name)
puts self.class
end
class A; end
A::B # => Class
How can I get A
in Object#const_missing
?
回答1:
def Object.const_missing(name)
puts self
end
来源:https://stackoverflow.com/questions/3314108/if-i-define-a-class-method-in-ruby-object-class-how-do-i-get-the-name-of-a-chil