开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜