Yossef Mendelssohn
10/18/2007 12:18:00 AM
]On Oct 17, 2:41 pm, "Thomas Adam" <thomas.ada...@gmail.com> wrote:
> On 17/10/2007, Giles Bowkett <gil...@gmail.com> 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