如何从定义相同名称的模块内部访问 ruby 中的顶级实体 [英] How to access a toplevel entity in ruby, from inside a module which defines the same name
本文介绍了如何从定义相同名称的模块内部访问 ruby 中的顶级实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一个模块中,我有一个名为 Process
的类.
Inside a module I have a class named Process
.
module M
Process= Class.new
Process::wait(0)
end
这会引发 NoMethodError
.
如何从模块内部访问顶层 Process
?这完全可能吗,而无需重新命名我的课程?
How do I access the toplevel Process
from inside the module? Is this at all possible, without renaiming my class?
推荐答案
::Process.wait(0)
这篇关于如何从定义相同名称的模块内部访问 ruby 中的顶级实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文