Hi --

On Fri, 9 Dec 2005, Hank Gong wrote:

> I carefully read two articles about classmethods and singleton concept.
> Now for me, the concept of classmethods seems not difficult for me now. It's
> just singleton methods for a class because class is also a object.
> However, the concept of singleton still not clear for me, also how to use
> them is also not making sense for me.
>

Basically an object's singleton class is a class created ad hoc, and
in a sense retroactively, for the sole purpose of being
the-class-where-this-object's-singleton-methods are defined and live.


David

P.S. Aside to Tom S.: I agree it's ad hoc in the sense of being for a
specific purpose, but I'm not sure I agree that it's ad hoc where the
"hoc" (actually the "hic", I guess, in the nominative case :-) is the
object itself.  One then runs into questions like: are instance
variables "ad hoc" variables?  etc.

-- 
David A. Black
dblack / wobblini.net

"Ruby for Rails", forthcoming from Manning Publications, April 2006!