Learning newb: regaring methods and class methods

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?

thanks

Hi –

On Thu, 13 Jul 2006, Dominic S. wrote:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs