From: Jim Menard Date: 2002-03-13T02:57:50+09:00 Subject: Re: Method type 'abstract' Peter Hickman writes: > Nat Pryce wrote: > > >In Ruby *all* methods are abstract unless implemented by a class. > > > >Or to put it in a more useful way, abstract methods are not required in a > >dynamically typed language such as Ruby, only in typed languages like Java > >or C++. > > > Not quite what I had in mind. If I create a class I will provide various > methods that a subclass can override. But in many cases they will pick > up the super classes' methods. However in the class I have in mind there > is one method that must exist in the subclass for which there is no > meaningfull default action that it can undertake, the subclass must > override this method. In Java I would mark the method as abstract rather > than just public or private and when I subclass it the compiler would > choke if I did not provide the override in the subclass. In Smalltalk it is common to implement this method in the superclass and have it call "subclassResponsibility", a method defined in Object. You could throw an exception. That's very useful for unit testing. Jim -- Jim Menard, jimm@io.com, http://www.io.com/~jimm/ "Alas! The onion you are eating is someone else's waterlily." -- A fortune cookie fortune