What does ::MyClass Ruby scope operator do?

后端 未结 2 1262
[愿得一人]
[愿得一人] 2020-12-10 15:28

What does the ::MyClass/MyModule scope operator do in Ruby, what is its purpose?

2条回答
  •  天命终不由人
    2020-12-10 15:33

    "global scope" just means the constant is defined on the Object class. So ::SomeModule is shorthand for Object::SomeModule

提交回复
热议问题