From: Xavier Noria Date: 2013-02-24T19:30:24+09:00 Subject: Re: How class objects call methods ? --089e013c6b1863930504d675e942 Content-Type: text/plain; charset=UTF-8 On Saturday, February 23, 2013, Xavier R. wrote: I was actually trying to see in how many ways class objects can call > methods? > Class objects do not actually call methods. Class objects are just instances of the class Class. For example, you can call Class#new on them, or #object_id for example. When the interpreter creates an object it internally associates the object with the class it is an instance of. For example, "" is an instance of String, and String is an instance of Class. In both cases, conceptually you have to visualize the instance has an internal slot that points to the class. When you call self.class you are accessing that slot. There is a difference, instances of the Class class have an internal method table associated to them. That table stores the instance method definitions you define, generally using the def keyword. That is a builtin behaviour. Method calling is done by the interpreter. When you invoke a method the interpreter checks that slot and looks for the method in the associated class (and more). --089e013c6b1863930504d675e942 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Saturday, February 23, 2013, Xavier R. wrote:

I was actually trying to see in how many ways class objects c= an call
methods?

Class objects do not actually call methods= . Class objects are just instances of the class Class. For example, you can= call Class#new on them, or #object_id for example.

When the interpreter creates an object it internally associates the ob= ject with the class it is an=C2=A0instance of. For example, "" is= an instance of String, and String is an instance of Class. In both cases, = conceptually you have to visualize=C2=A0the instance has an internal slot t= hat points to the class. When you call self.class you are accessing that sl= ot.

There is a difference, instances of the Class class hav= e an internal method=C2=A0table associated to them. That table stores the i= nstance method definitions you define, generally using the def keyword. Tha= t is a builtin behaviour.

Method calling is done by the interpreter. When you inv= oke a method the interpreter checks that slot and looks for the method in t= he associated class (and more).
--089e013c6b1863930504d675e942--