From: Dave Thomas Date: 2002-02-26T03:34:12+09:00 Subject: Re: Style Question Ron Jeffries writes: > I don't understand the notation above with class << etc. What's up with > that? How is it different from > > class Set > protected :new > end 'new' isn't an instance method of class Set, so the line above wouldn't work. Instead, new is defined in Set's metaclass. You can pop into the metaclass using the singleton class thingy. class < I think I get this. It's basically the same deal but avoids having to > predeclare the subclasses up at the top, right? Definitely a better > way. Yes - the key is to encapsulate the type-specific factories inside the source for the types, and not in the source for the base class. > >This schema means you can add new concrete representations without > >ever changing the base class. > > I guess you mean without ever editing the base class's file if it > has its own. Certainly defining a method on it is changing the class > itself? Picky :) Dave