From: Ben Tompkins Date: 2007-09-03T04:10:33+09:00 Subject: Re: Shouldn't it be class >> self , or am I dyslexic? unknown wrote: > Hi -- Perhaps you were misled by the first sentence of my reply to Sebastian, in which I said 'you are basically correct to say that "self inherits from the singleton class.".' Note the "basically" qualification. Apart from that sentence, my entire exposition prior to this reply, which spans two postings, argues *against* the idea that "<<" signifies inheritance in: class << object ... end In pseudocode, this translates into: object.method1 # error object.method2 # error 1. temp = Class.new { method1, method2, ... } 2. temp.superclass = object.class 3. object.class = temp object.method1 # OK object.method2 # OK Thus 1-3 might be more succinctly expressed as: Class.new { method1, method2 } >> object which is very close to: class >> object # instead of class << object def method1 ... end def method2 ... end end Got it? nbits > > I'm sorry, but I had to chuckle at the use of the word "intuitive" > after that explanation :-) > > I wouldn't think of class << obj as having anything at all to do with > inheritance. It's more like this, in terms of how the class keyword > works: > > class expr > > where expr can be: > > A > A < B > << arbitrary_object > > So the inheritance < is more like: > > class (A < B) > > and the singleton notation is more like: > > class (<< obj) > > Remember, also, that the class keyword isn't itself a class > identifier; you're not looking for "the class that is >> object", but > the class that is, so to speak, yielded from object. (Or something.) > It's not a notation that relates very closely to any other. > > > David -- Posted via http://www.ruby-forum.com/.