在Ruby中,我理解了它的基本思想extend.但是,这段代码中发生了什么?具体来说,做extend什么?它只是将实例方法转换为类方法的便捷方式吗?你为什么要这样做,而不是从一开始就指定类方法?
module Rake
include Test::Unit::Assertions
def run_tests # etc.
end
# what does the next line do?
extend self
end
Run Code Online (Sandbox Code Playgroud) ruby ×1