From: Wilson Bilkovich Date: 2007-09-27T13:45:42+09:00 Subject: Re: Syntax for .new ? On 9/27/07, Phrogz wrote: > On Sep 26, 9:49 pm, "Wilson Bilkovich" wrote: > > > See http://phrogz.net/RubyLibs/RubyMethodLookupFlow.png > > > > > (There's no official guarantee that the diagram above is correct, but > > > I have not yet been able to find fault with it, and it has been > > > reviewed and had corrections made thanks to some people quite > > > familiar with Ruby.) > > > > "ri Class" also has a nice simple ASCII diagram that can be more > > approachable for new people. > > > > Classes, modules, and objects are interrelated. In the diagram > > that follows, the vertical arrows represent inheritance, and the > > parentheses meta-classes. All metaclasses are instances of the > > class `Class'. > > > > +------------------+ > > | | > > Object---->(Object) | > > ^ ^ ^ ^ | > > | | | | | > > | | +-----+ +---------+ | > > | | | | | > > | +-----------+ | | > > | | | | | > > +------+ | Module--->(Module) | > > | | ^ ^ | > > OtherClass-->(OtherClass) | | | > > | | | > > Class---->(Class) | > > ^ | > > | | > > +----------------+ > > Interesting that you would characterize it as such. It's certainly > both official and correct (and was definitely helpful in creating my > own version), but I personally found it wholly confusing. It was only > through a fair amount of experimentation, repeatedly re-reading the > explanation (what's a 'meta-class' again?), and squinting my eyes at > the diagram that I was able to decipher it. > > But, if that diagram does it for you, all the better. It certainly has > less boxes and lines. > I guess that one is clear to me because it quickly shows "everything has a metaclass", after which you can pretty much ignore anything in parens. Heh. On the other hand, maybe I'm just mis-remembering how I actually learned the structure when I first picked Ruby up.