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


David

-- 
David A. Black (dblack / wobblini.net)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

"Ruby for Rails" chapters now available
from Manning Early Access Program! http://www.manning.com/books/black