From: Robert Klemme Date: 2004-12-13T18:42:24+09:00 Subject: Re: Abstracts and Interfaces in Ruby? "Miles Keaton" schrieb im Newsbeitrag news:59b2d39b04121222201b1064c5@mail.gmail.com... > What's the recommended Ruby way to do abstract classes and abstract methods? > > Related : what's the Ruby way for interfaces? > > While Googling for it, I was thinking about what abstracts and > interfaces are used for in Java and PHP5 ... and it came down to > stopping with errors if a certain method was NOT implemented. > > So... is that kind of thing just not the Ruby Way? (To give you > errors for not doing something.) > > Would I just do workarounds to say: > > class AbstractSomething > def method > puts "error - abstract!" > end > end You'd rather throw an exception here. But this would happen anyway if the method remained undefined and someone attempted to invoke it. So you don't really gain much apart maybe from a different error message and rdoc documentation for this method. > Or does Ruby have a whole different approach to this that I missed somewhere? Usually we don't do this in Ruby (=> "Duck Typing"). Otherwise see Gabriele's hints. Kind regards robert