From: ara.t.howard@... Date: 2006-03-13T09:16:30+09:00 Subject: Re: [RCR] abstract method in Ruby On Mon, 13 Mar 2006, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [RCR] abstract method in Ruby" > on Sun, 12 Mar 2006 16:38:44 +0900, "kwatch" writes: > > |The following code itself describes that method each() is abstract. > |It's more descriptive. > | > | module Enumerable > | abstract_method :each > | def map > | arr = [] > | each { |elem| arr << yield(elem) } > | arr > | end > | end > > I'm afraid that it doesn't work for some cases, for example: > > class Base > def each > ... > end > end > > class Derived < Base > include Enumerable > ... > end > > The abstract "each" method defined in Enumerable overrides the "each" > in the Base class. I'm not against the idea of abstract (or deferred) > method, but sometimes it's not that simple. how about something very simple? i use this in my own code class Module def abstract_method m define_method(m){|*a| raise NotImplementedError} end end module Interface abstract_method "foo" abstract_method "bar" end class C include Interface end it's quite nice for the rdocs. regards. -a -- share your knowledge. it's a way to achieve immortality. - h.h. the 14th dali lama