From: Josh Cheek Date: 2013-07-25T03:22:41+09:00 Subject: Re: class <=> module --001a11c34e329c90ad04e245fefb Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jul 24, 2013 at 12:54 PM, wrote: > Am 24.07.2013 15:34, schrieb Josh Cheek: > > On Wed, Jul 24, 2013 at 7:51 AM, > > wrote: > > > > Am 24.07.2013 14 :35, schrieb Josh Cheek: > > > > On Wed, Jul 24, 2013 at 1:10 AM, > > > >> wrote: > > > > > > And you forgot to mention: classes can inherit only from a > > single other > > class (a conscious decision by Matz), but you can include > > many modules. > > Seems difficult to unify that in one concept. > > > > > > That seems inaccurate to me: > > > > C1 = Class.new Object > > C2 = Class.new C1 > > C3 = Class.new C2 > > > > > > I was alluding to multiple inheritance, meaning a class > > inherits _directly_ from more than one superclass. > > > > > > I still don't understand. I showed that you can inherit from multiple > > classes like you can inherit from multiple modules. Yes there are other > > No, they behave differently! > The modules are *not* superclasses of the classes they are mixed into: > > They are, the code examples just say otherwise because Ruby lies to you. It's the same as how the singleton class is actually the object's class, even though when you ask it about its class, it will tell you what it was instantiated from. This used to be a good blog about it http://web.archive.org/web/20110214135710/http://carboni.ca/blog/p/Modules-How-Do-They-Workbut sadly it's down now, so you can't see the images. -Josh --001a11c34e329c90ad04e245fefb Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Jul 24, 2013 at 12:54 PM, <sto.mar@web.de> wrote:
<= div class=3D"gmail_quote">
Am 24.07.2013 15= :34, schrieb Josh Cheek:
> On Wed, Jul 24, 2013 at 7:51 AM, <sto.mar@web.de
> <mailto:sto.mar@web.de>>= ; wrote:
>
> =A0 =A0 Am 24.0= 7.2013 14 <tel:24.07.2013%2014>:35, schrieb Josh Cheek:
>
> =A0 =A0 =A0 =A0 On Wed, Jul 24, 2013 at 1:10 AM, <sto.mar@web.de
> =A0 =A0 =A0 =A0 <mailto:sto.mar@w= eb.de>
> =A0 =A0 =A0 =A0 <mailto:sto.mar@web.de <mailto:sto.mar@web.de>>> wrote:
>
>
> =A0 =A0 =A0 =A0 =A0 =A0 And you forgot to mention: classes can inherit= only from a
> =A0 =A0 =A0 =A0 single other
> =A0 =A0 =A0 =A0 =A0 =A0 class (a conscious decision by Matz), but you = can include
> =A0 =A0 =A0 =A0 many modules.
> =A0 =A0 =A0 =A0 =A0 =A0 Seems difficult to unify that in one concept.<= br> >
>
> =A0 =A0 =A0 =A0 That seems inaccurate to me:
>
> =A0 =A0 =A0 =A0 C1 =3D Class.new Object
> =A0 =A0 =A0 =A0 C2 =3D Class.new C1
> =A0 =A0 =A0 =A0 C3 =3D Class.new C2
>
>
> =A0 =A0 I was alluding to multiple inheritance, meaning a class
> =A0 =A0 inherits _directly_ from more than one superclass.
>
>
> I still don't understand. I showed that you can inherit from multi= ple
> classes like you can inherit from multiple modules. Yes there are othe= r

No, they behave differently!
The modules are *not* superclasses of the classes they are mixed into:


They are, the = code examples just say otherwise because Ruby lies to you. It's the sam= e as how the singleton class is actually the object's class, even thoug= h when you ask it about its class, it will tell you what it was instantiate= d from.

This used to be a good blog about it=A0http://web.archive.org/web/20110214135710/http://carboni.ca/bl= og/p/Modules-How-Do-They-Work but sadly it's down now, so you can&#= 39;t see the images.

-Josh
--001a11c34e329c90ad04e245fefb--