1
我想知道的两种情况之间的差异:这两种情况有什么区别?
module M
# def self.append_features(base)
# if base < self then p true
# else p false
# end
# end
end
class C
include M
end
if C < M then p true
else p false
end
输出是:
true
但如果我删除了评论,输出为:
false
false
为什么输出与以前的输出不同?
我不认为这段代码会做你认为它的作用。比较这些常数是没有意义的。 – sevenseacat
有[[<]](http://ruby-doc.org/core-2.3.0/Module.html#method-i-3C)方法来测试模块是否是另一个模块的子类,但这不是这里的情况。 – tadman
谢谢你的回复,它不是比较常量,检查C类是否是M的子类。 – Messi