> -----Original Message-----
> From: nosuzuki / e-mail.ne.jp [mailto:nosuzuki / e-mail.ne.jp]On Behalf Of
> Gregg T. Geiger
> Sent: Thursday, December 28, 2000 05:40 AM
> To: ruby-talk ML
> Subject: [ruby-talk:8174] Multiple Inheritance
>
>
> Just looking to do something like
>
> class Child < (Father, Mother)
> end
>
> with Father and Mother having been previously defined.  Obviously the syntax
> is wrong, but is MI possible w/ Ruby?
Hi,

you surely saw the answers that "modules + include" are a substitute for MI.  I tend
to believe that the "modules + include" mechanism is closer to the C++ template
mechanism.  This is not that surprising in light of Rubys typeless function
parameters leaving all function definitions with a ``templatey" aftertaste.

Here is simple example which probably will not win me any price money for  efficient
(or illustrative value I am afraid)

module Between
# This module can be include into any Class
#  providing a sensible  #<=" and #==  method

    def  between? (a,b) #  is self bewtween min(a,b) and max(a,b)  ?
            return  ( (a <= self ) && (self <= b ) ||
                           (b <= self ) && (self <= a ) )
    end
    def  strictly_between?
            return  self.between? (a,b) &&  self != a || self != b
    end
     # maybe define other stuff
end

class Fixnum
    include Between     # We even have a template
                                      # specializations mechanism -
                                      # thanks to overriding
    def  between? (a, b)
            return 0 <=  (a - self) * ( self  - b)
     end
end

class String
        include Between
        # the Fixnum  trick won't work
end

With these definition you can call

    13.strictly_between? (14,  9)               #  true
     "between".between? ("after","before") #  false

Christoph

> Thanks.
>
>
>