加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

红宝石 – 动态需要文件?

发布时间:2020-12-16 20:38:39 所属栏目:百科 来源:网络整理
导读:有谁知道Ruby的要求,告诉我如果以下是有效的语法: class Something def initialize(mode) case mode when :one then require 'some_gem' when :two then require 'other_gem' end endends = Something.new 如果是这样,需要将gem放在全局命名空间中,就像在文
有谁知道Ruby的要求,告诉我如果以下是有效的语法:
class Something

  def initialize(mode)
     case mode
     when :one then require 'some_gem'
     when :two then require 'other_gem'
     end
  end

end

s = Something.new

如果是这样,需要将gem放在全局命名空间中,就像在文件顶部一样?

解决方法

If so,would the require place the gem
into the global namespace as the same
require at the top of the file would?

是.要求没有范围,而负载.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读