Hi,
In message "Re: [RCR] abstract method in Ruby"
on Sun, 12 Mar 2006 16:38:44 +0900, "kwatch" <kwa / kuwata-lab.com> 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.
matz.