From: Ryan Davis Date: 2009-07-15T04:36:13+09:00 Subject: Re: Twelve rules of Ruby On Jul 14, 2009, at 06:16 , David A. Black wrote: > Not sure why they wrapped weirdly (at least on my screen), but here's > a correctly-wrapped version, I hope. Rick did a very good job with some of the philosophical wanking but I thought I'd expand a bit on David's list... I have to be a pedant now and then :) (please note, I'm still pre-caffeine... I'm sure I missed something in the editing phase) > 1. Classes are objects. I prefer to tell my students: EVERYTHING is an object, even classes. I think it conveys the ontology a bit better. > 2. Objects don't "have" methods; they have the intelligence to resolve > messages by looking for methods along their class/module lookup > path. See #1. Classes, modules, and their anonymous kin _have_ methods. > 3. Every instance variable you ever see in any Ruby program belongs to > whatever object "self" is at that moment, without exception. (Which > is one reason that understanding how "self" gets assigned is > absolutely vital.) > 4. A code block is a syntactic construct, not an object. See #1. EVERYTHING is an object, even blocks. > 5. Class variables are not class variables, in the sense of belonging > to a particular class. They are class hierarchy variables. I know what you're getting at, but it might be worth having the contrast of class instance variables in there so others understand too. > 6. Inheritance (A < B) is not the same as, and not related to, nesting > (A::B).