得到singleton类?

    xiaoxiao2024-06-03  106

    在Ruby中,无论类或者对象,都有一个singlton类(或者称为metaclass),有兴趣的话读读过去写的这篇《Ruby的对象模型》。当我们获取某个类或者对象的class属性时,其实会忽略c ruby层次上的singleton类,那么我们如何得到singleton类呢?比较有趣的做法: singletonclass=class<<Test;self;end 对于对象,也是如此: test=Test.new metaclass=class<<test;self;end 文章转自庄周梦蝶  ,原文发布时间2007-10-31 相关资源:敏捷开发V1.0.pptx
    最新回复(0)