11

in ruby, :: namespaces the module and class. But I often see :: at the beginning of the class name like the following:

#snippet of gollum gem def page_class @page_class || if superclass.respond_to?(:page_class) superclass.page_class else ::Gollum::Page end end 

What does that :: stands for if its in the beginning?

2

1 Answer 1

25

It is to resolve against the global scope instead of the local.

class A def self.global? true end end module B class A def self.global? false end end def self.a puts A.global? puts ::A.global? end end B::a 

prints

false true 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.