【发布时间】:2013-03-14 20:22:58
【问题描述】:
我所知道的单例方法可以由定义它的对象调用。现在在下面的示例中,C 也是Class 的对象和在Class 对象C 上定义的单例方法a_class_method。那么另一个Class 对象D 如何能够
打电话给a_class_method?
在这个例子中对象
individuation的原则如何成立?
class C
end
#=> nil
def C.a_class_method
puts "Singleton method defined on #{self}"
end
#=> nil
C.a_class_method
#Singleton method defined on C
#=> nil
class D < C
end
#=> nil
D.a_class_method
#Singleton method defined on D
#=> nil
【问题讨论】: