【发布时间】:2009-11-14 03:26:23
【问题描述】:
在Ruby中,我了解extend的基本思想。但是,这段代码发生了什么?具体来说,extend 做了什么?它只是将实例方法变成类方法的一种方便方法吗?为什么要这样做而不是从一开始就指定类方法?
module Rake
include Test::Unit::Assertions
def run_tests # etc.
end
# what does the next line do?
extend self
end
【问题讨论】:
标签: ruby