From: Jonathan Leighton Date: 2006-03-26T23:25:26+09:00 Subject: Re: Noob: use of the double colon On Sun, 2006-03-26 at 22:33 +0900, dblack@wobblini.net wrote: > Hi -- > > On Sun, 26 Mar 2006, NuclearFusion wrote: > > > Hi, > > > > there seems to be more than one way to execute class methods. > > I've seen the form (I use the classmethod new as an example): > > newObject = Classname::new > > but also > > newObject = Classname.new > > Bothe seem to work OK. > > Is there a difference? If yes, what is the difference? > > They do both work. I've never understood why the :: exists for this > purpose, since the . is the normal way of sending messages to objects > and works perfectly well whether or not the receiver is a class. It's > on my very short list of things I'd like to see removed from Ruby. > > > Also I see :: being used in the context of modules. Can you tell me > > about that as well? > > That's for looking up names of constants in nested scopes: > > module M > X = 1 > end > > puts M::X # 1 While we're on the topic -- I've never exactly understood what placing the double colon at the beginning does? eg... ::FooModule::FOO_CONSTANT ? Cheers -- Jonathan Leighton http://turnipspatch.com/ | http://jonathanleighton.com/ | http://digital-proof.org/