From: Yossef Mendelssohn Date: 2007-10-18T09:18:25+09:00 Subject: Re: abstract superclasses ]On Oct 17, 2:41 pm, "Thomas Adam" wrote: > On 17/10/2007, Giles Bowkett wrote: > > > I sometimes use the Java thing of an abstract superclass in Ruby. I > > usually just set up the abstract parent so that it'll break if used > > directly. Is it better to just use Modules? Have other people run into > > this? > > I'd use a Module, yes. Or a class: > > class SomeClassMimickingAbstract > private_class_method :new > end > > But you don't need to think this way in Ruby -- unlike Java, Ruby is > weakly typed. > > -- Thomas Adam How do you suggest to use that class? I understanding keeping the "abstract" class from being instantiated, but what about the concrete classes, the ones you're going to use? class RealThing < SomeClassMimickingAbstract # now make .new public again end Ugly, isn't it? Of course, that's just more fuel for the "don't do this in Ruby" fire. -- -yossef