Hi --

On Thu, 13 Jul 2006, Dominic Son wrote:

> hi, i just need to know if i'm on the right trax regarding ruby:
>
> a '::' method class attached to another constant or variable will tell
> that constant/variable to use all methods under it's class where
>
> as '.' tells ruby to use only 1 method.
>
> but before using that method, we have to call for the 'new class' that
> method belongs to...
>
> Can someone please tell me if any of the above is wrong?

:: is chiefly for navigating paths through nested classes and modules:

   class A
     module B
       class C
       end
     end
   end

   A::B::C.new   # new instance of the inner class

. is for calling methods -- like C.new, above.

You'll sometimes see :: used for calling methods when the receiver is
a class or module, but personally I think it's simpler and clearer just
to use . for calling methods.


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
http://www.manning.com/black     => RUBY FOR RAILS, the Ruby book for
                                                     Rails developers
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
dblack / wobblini.net              => me