Mark Volkmann
3/26/2006 3:39:00 PM
On 3/26/06, dblack@wobblini.net <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.
Some might say this is another example of TIMTOWTDI.
However, like you, I'd like to see it changed to only use ".".
> > 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
It seems to me that dots could be used for constant references too.
Maybe someone will point out a reason why this would complicate
parsing.
--
R. Mark Volkmann
Object Computing, Inc.