Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Meaning of ::

Reply
Thread Tools

Meaning of ::

 
 
Guido Granobles
Guest
Posts: n/a
 
      11-07-2010
Hi!.. I'm very new with Ruby and I wold like to know what does it mean
the four points when I am doing inheritance. Like:
Code:
class1::base
I know that it represents a constant but how I should interpret that.

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Scott Gonyea
Guest
Posts: n/a
 
      11-07-2010
Class and Module names must be in their "proper case" form. So, =
"Class1::Base". Constants are in all caps, while methods and variable =
names are lower case.

The :: operator is used to delimit namespace. Without using namespaces =
for your library, everyone who wanted to call their class "Base" would =
collide with each other. You'd get some very unpredictable behavior.

Besides preventing namespace collisions, it helps you to organize and =
describe your objects.

Scott

On Nov 6, 2010, at 8:11 PM, Guido Granobles wrote:

> Hi!.. I'm very new with Ruby and I wold like to know what does it mean
> the four points when I am doing inheritance. Like:
>
Code:
> class1::base
>
> I know that it represents a constant but how I should interpret that.
>=20
> --=20
> Posted via http://www.ruby-forum.com/.
>=20



 
Reply With Quote
 
 
 
 
Zhi-Qiang Lei
Guest
Posts: n/a
 
      11-07-2010
What about code like:

:igest::MD5.hexdigest "xxx"

Why is the :: before Digest module nothing?

On Nov 7, 2010, at 1:29 PM, Scott Gonyea wrote:

> Class and Module names must be in their "proper case" form. So, =

"Class1::Base". Constants are in all caps, while methods and variable =
names are lower case.
>=20
> The :: operator is used to delimit namespace. Without using =

namespaces for your library, everyone who wanted to call their class =
"Base" would collide with each other. You'd get some very unpredictable =
behavior.
>=20
> Besides preventing namespace collisions, it helps you to organize and =

describe your objects.
>=20
> Scott
>=20
> On Nov 6, 2010, at 8:11 PM, Guido Granobles wrote:
>=20
>> Hi!.. I'm very new with Ruby and I wold like to know what does it =

mean
>> the four points when I am doing inheritance. Like:
>>
Code:
>> class1::base
>>
>> I know that it represents a constant but how I should interpret that.
>>=20
>> --=20
>> Posted via http://www.ruby-forum.com/.
>>=20

>=20
>=20



Best regards,
Zhi-Qiang Lei
http://www.velocityreviews.com/forums/(E-Mail Removed)


 
Reply With Quote
 
Jesús Gabriel y Galán
Guest
Posts: n/a
 
      11-07-2010
On Sun, Nov 7, 2010 at 9:37 AM, Zhi-Qiang Lei <(E-Mail Removed)> wrote:
> What about code like:
>
> :igest::MD5.hexdigest "xxx"
>
> Why is the :: before Digest module nothing?


That means to refer to the top most Digest constant, to avoid
referencing the wrong one in cases like this:

module Test
module Digest
# my own Digest module
end

class TestClass
Digest # refers to my own module
:igest # refers to the Digest module defined at the top level
end
end

Jesus.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding search queries, semantics, and "Meaning" ...aren't weall looking for meaning? 5lvqbwl02@sneakemail.com Python 4 01-14-2009 02:28 PM
use work.my_package.all-->what exactly meaning of this Parthav VHDL 4 01-13-2006 07:50 PM
WHAT IS THE MEANING *FESWANY MCSE 3 01-28-2005 02:55 PM
Meaning of word "develop" in the exam (70-300) TomTom MCSD 10 08-13-2004 04:39 PM
Meaning of output value? Sander Odekerken VHDL 2 05-18-2004 05:41 PM



Advertisments