[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Is this old style Ruby?
From:       "David A. Black" <dblack () wobblini ! net>
Date:       2005-02-15 16:01:12
Message-ID: Pine.LNX.4.61.0502150756020.27132 () wobblini
[Download RAW message or body]

Hi --

On Wed, 16 Feb 2005, Nikolai Weibull wrote:

> * centrepins@gmail.com (Feb 15, 2005 16:16):
>> So you would say use :: only for constant access, and use '.' for
>> method access be it in a class or module?
>
> Well class-methods are constant as well in a sense, hence the use of
> "::" in Why's book and it being the (at least old-school) idiom,

I disagree; I don't think class methods are constant in any sense, any
more than any other method definition.  They're basically just
per-object/singleton method definitions:

   class C
     def C.x
     end
   end

like

   str = "abc"
   def str.x
   end

etc.  They have a semi-special status in the language (e.g., the
existence of the #class_methods method), but when you call one, you're
just sending a message to an object for method-call-based response.
That's different from retrieving a constant, but it's not different
from calling a method on any other object.


David

-- 
David A. Black
dblack@wobblini.net

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic