How to access the base namespace in Ruby?

后端 未结 2 713
北荒
北荒 2021-02-05 02:38

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

And I need to access the ruby File class.

In php this could be done like th

2条回答
  •  礼貌的吻别
    2021-02-05 03:07

    I'm not sure what you're asking, but if you are inside of module Foo and you reference class Bar, then ruby will look for Foo::Bar. To look just for Bar, you should reference ::Bar (of course, this Bar should be defined in "global" scope, outside of Foo).

提交回复
热议问题