A question about metaclass


#1

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


#2

Sam K. 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


#3

james_b wrote:

Sam K. 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 M., a real gem!

Regards, Bernhard