From: Robert Klemme Date: 2007-06-03T02:05:20+09:00 Subject: Re: so lost on singleton, metaclass and virtual class On 02.06.2007 18:30, Dorren wrote: > Q1: in pick axe book page 364, it talks about metaclass should be a > singleton class. but when I run the following code, class's object_id > are the same for all instance, but the metaclass object_id are > different for each object instance, is the code wrong or what? The term "singleton class" has been discussed a lot. Other names have been suggested but I guess "singleton class" sticks because the book uses it. :-) Basically it just means that there is one singleton class per instance. This class is invisible most of the time - you basically see it only when you do class< > Q2: from pick axe book 364-367, it used singleton, metaclass, and > virtual class definition interchangeably. are they all the same thing > or not? Um, I would have to check with my copy which I don't have here with me. But it is very possible. > Q3: from page 365, > "To handle per-object attributes, Ruby provides a classlike some- > thing for each object that is sometimes called a singleton class." > if runtime create something new for EACH object, how can it be called > singleton? See my explanation above. Kind regards robert