如何在Ruby中访问基本名称空间? [英] How to access the base namespace in Ruby?

查看:101
本文介绍了如何在Ruby中访问基本名称空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在文件模块所在的名称空间(在另一个模块内部)中编写代码

I'm writing code in a namespace where the File module exists (inside another module)

我需要访问ruby File类.

And I need to access the ruby File class.

在php中,可以这样完成:\ File

In php this could be done like this: \File

如何在红宝石中做到这一点?

How to do that in ruby?

推荐答案

::File

使用::进行前缀访问名称空间树的根".

Prefixing with :: accesses the 'root' of the namespace tree.

这篇关于如何在Ruby中访问基本名称空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆