Re: extend keyword in class definition
- From: "David A. Black" <dblack@xxxxxxxxxxx>
- Date: Tue, 30 Sep 2008 05:37:00 -0500
Hi --
On Tue, 30 Sep 2008, Sebastian Hungerecker wrote:
ruud grosmann wrote:
Isn't a singleton method a method that applies to the
singleton class of one object?
It is a method that is defined on the singleton class of an object, yes.
As a singleton class by definition only has one instance that means that a
singleton method is a method that can be called on a single object and that
object only.
Although:
class C
end
class D < C
end
def C.x
end
D.x # subclass can call superclass's singleton methods
Technically, it's also true that if you extend an object with a
module, you're not really writing singleton methods, since the methods
in the module are available to other objects that use the module. The
singleton_method_added callback won't get called, for example.
David
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL
Advancing with Rails January 19-22 Fort Lauderdale, FL *
* Co-taught with Patrick Ewing!
See http://www.rubypal.com for details and updates!
.
- Follow-Ups:
- Re: extend keyword in class definition
- From: ruud grosmann
- Re: extend keyword in class definition
- References:
- extend keyword in class definition
- From: ruud grosmann
- Re: extend keyword in class definition
- From: James Coglan
- Re: extend keyword in class definition
- From: ruud grosmann
- Re: extend keyword in class definition
- From: Sebastian Hungerecker
- extend keyword in class definition
- Prev by Date: Re: extend keyword in class definition
- Next by Date: Re: extend keyword in class definition
- Previous by thread: Re: extend keyword in class definition
- Next by thread: Re: extend keyword in class definition
- Index(es):
Relevant Pages
|