> My understanding was that the singleton class is what you obtain when you
> call self.class in instance scope
I think it is not a singleton class, but a normal class.
> metaclass and eigenclass are interchangeable terms for
> what you obtain if you call class << self; self; end in instance scope.
This is just an eigenclass, and I understand that the term
"eigenclass" is interchangeable with "singleton class".
Please see the following example:
class Object
# this method return the singleton class of the receiver
def singleton_class
class << self; self end
end
end
# obtain the singleton class of a String object
sc = "aaaa".singleton_class
p sc #=> #<Class:#<String:0x00000001442a50>>
begin
# if you try to create a instance of a singleton class...
sc.new # raise error!!
rescue => err
puts err #=> can't create instance of singleton class
# (ruby 1.9.1)
#=> can't create instance of virtual class
# (ruby 1.

# this error message tell us that +sc+ is
# an singleton class
end
I don't know the term "metaclass" is interchangeable with the term
"eigenclass"... I think a metaclass is a Class object or a singleton
class of a Class object, but I'm not sure.
--
nobuoka