Forum: Ruby A question about metaclass

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ca0b18ec9e11dc777b2b8084fe5d5f90?d=identicon&s=25 sam.s.kong (Guest)
on 2005-11-24 02:31
(Received via mailing list)
Hi!

Some code first...

--------
class C
end

obj = C.new  #<-- Question here.
--------

My question is where the C.new method is.
The class Class or C's singleton class?

According to PickAxe2, it seems that C.new is in Class.
However, according to Little Ruby book, it seems that C.new is in C's
metaclass.

Which is right and how can we confirm that?

TIA.

Sam
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 james_b (Guest)
on 2005-11-24 02:51
(Received via mailing list)
Sam Kong wrote:
>
> My question is where the C.new method is.
> The class Class or C's singleton class?
>
> According to PickAxe2, it seems that C.new is in Class.
> However, according to Little Ruby book, it seems that C.new is in C's
> metaclass.

What is "Little Ruby book"?


James
A0bc1d60fb52b1bd8f0c44b2f43d196c?d=identicon&s=25 Bernhard (Guest)
on 2005-11-24 09:25
james_b wrote:
> Sam Kong wrote:
>>
>> My question is where the C.new method is.
>> The class Class or C's singleton class?
>>
>> According to PickAxe2, it seems that C.new is in Class.
>> However, according to Little Ruby book, it seems that C.new is in C's
>> metaclass.
>
> What is "Little Ruby book"?
>
>
> James

http://www.visibleworkings.com/little-ruby/ ,"A Little Ruby, A Lot of
Objects", book fragment by Brian Marick, a real gem!

Regards, Bernhard
This topic is locked and can not be replied to.