Hi, looking at a Ruby code I’ve found this:
repo = ::Logging::Repository.instance
What does the first :: mean?
Thanks.
Hi, looking at a Ruby code I’ve found this:
repo = ::Logging::Repository.instance
What does the first :: mean?
Thanks.
It’s an “ensure you’re pulling from the top level”. Works exactly the
same as in C++
Jason
On Aug 21, 2008, at 2:41 PM, Iñaki Baz C. wrote:
Hi, looking at a Ruby code I’ve found this:
repo = ::Logging::Repository.instance
What does the first :: mean?
Thanks.
start a the ‘top’ namespace
class A
end
module M
class A
end
p ::A # the top level one, not the normally scoped one
end
El Jueves, 21 de Agosto de 2008, Jason R.
escribió:> It’s an “ensure you’re pulling from the top level”. Works exactly the
same as in C++
Let me be sure:
module A
CONS = “AAA”
module B
CONS = “BBB”
end
end
module A
module B
puts ::CONS
end
end
=> AAA
Is it?
Thanks a lot.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs