在Ruby语言中,我理解了extend
的基本思想。然而,在这段代码中发生了什么?具体地说,extend
做了什么?这只是一种将实例方法转换为类方法的便捷方法吗?为什么要这样做,而不是从一开始就指定类方法?
module Rake
include Test::Unit::Assertions
def run_tests # etc.
end
# what does the next line do?
extend self
end
https://stackoverflow.com/questions/1733124
复制相似问题