If I define a class-method in Ruby Object class, h

2019-08-02 23:19发布

问题:

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