相关疑难解决方法(0)

Ruby:扩展自我

在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

113
推荐指数
4
解决办法
3万
查看次数

标签 统计

ruby ×1