From: avi@...4.com (Avi Bryant) Date: 2002-02-26T04:04:22+09:00 Subject: Re: Style Question Ron Jeffries wrote in message news:<12B6609B12CD5F7D.4DEF63A6DE4AC5F0.77925861F11FD441@lp.airnews.net>... > So what I've got now is that Sets are created by factory methods such as > > Set.create(anArray) > > which returns an EnumeratedSet whose contents are the elements of the > Array, wrapped as they need to be for the set's purposes. > > Of course (he said, after finally figuring it out) this means that no > one can do Set.new(anything), because that will implicitly call > initialize and MUST return an instance of Set, which is illegal because > Set is abstract. I guess that's OK with me. What about using double dispatch? For example, class Set class << self alias :new :basicNew def new(anObject) anObject.asSet end end end class Array def asSet EnumerableSet.basicNew(self) end end class Fibble def asSet FibbleSet.basicNew(self) end end Set.new(anArray) #=> an ArraySet Set.new(aFibble) #=> a FibbleSet