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 Young <alex@blackkettle.org>
To: ruby-talk ML <ruby-talk@ruby-lang.org>
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
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around