[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

What does :: mean at the beginning?

Iñaki Baz Castillo

8/21/2008 8:41:00 PM

Hi, looking at a Ruby code I've found this:

repo =3D ::Logging::Repository.instance

What does the first :: mean?

Thanks.

=2D-=20
I=C3=B1aki Baz Castillo

3 Answers

Jason Roelofs

8/21/2008 8:49:00 PM

0

It's an "ensure you're pulling from the top level". Works exactly the
same as in C++

Jason

On Thu, Aug 21, 2008 at 4:41 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
:
> Hi, looking at a Ruby code I've found this:
>
> repo =3D ::Logging::Repository.instance
>
> What does the first :: mean?
>
> Thanks.
>
> --
> I=F1aki Baz Castillo
>
>

ara.t.howard

8/21/2008 8:51:00 PM

0


On Aug 21, 2008, at 2:41 PM, I=F1aki Baz Castillo wrote:

> Hi, looking at a Ruby code I've found this:
>
> repo =3D ::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

a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being =20
better. simply reflect on that.
h.h. the 14th dalai lama




Iñaki Baz Castillo

8/21/2008 8:55:00 PM

0

El Jueves, 21 de Agosto de 2008, Jason Roelofs escribi=F3:
> 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 =3D "AAA"
module B
CONS =3D "BBB"
end
end

module A
module B
puts ::A::CONS
end
end

=3D> AAA


Is it?

Thanks a lot.


=2D-=20
I=F1aki Baz Castillo