开发者

If I define a class-method in Ruby Object class, how do I get the name of a child class calling this method?

开发者 https://www.devze.com 2023-01-08 17:44 出处:网络
Example开发者_运维问答 def Object.const_missing(name) puts self.class end class A; end A::B # => Class

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?


def Object.const_missing(name)
  puts self
end
0

精彩评论

暂无评论...
验证码 换一张
取 消