Re: :: and

thx everyone for the reply. for the fine examples (some i don’t quite
understand yet…) as i’m still in the very early stages yet…

can i assume that it’s simplier to use . than :: for references to
methods?

thanks!

----- Original Message ----
From: Alex Y. [email protected]
To: ruby-talk ML [email protected]
Sent: Wednesday, November 7, 2007 10:13:01 AM
Subject: Re: :: and .

joey eisma wrote:

hi!

reading through some tutorial, i noticed the author would interchange using :: and . to call methods. i see they both give the same result.

i was wondering if there is any other difference between the two? (other than convenience maybe?). when would you use one over the other?

In addition to the other answers, there’s one place that you can only
use ‘::’ rather than ‘.’, and that’s when you’re specifying that your
constant should be searched for in the root namespace:

Bar = 42
module Foo
Bar = 23
def Foo.show
p ::Bar
p Bar
end
end

Foo.show outputs:
42
23


Alex

On Nov 7, 2007 3:01 PM, joey eisma [email protected] wrote:

thx everyone for the reply. for the fine examples (some i don’t quite understand yet…) as i’m still in the very early stages yet…

can i assume that it’s simplier to use . than :: for references to methods?

thanks!

Yep. Seems like bad form to me to use :: for no real reason.