From: no_private_replies@... (Morel) Date: 2008-02-22T06:34:58+09:00 Subject: Re: Reusing the existing code. wrote: > On 21 ???, 13:02, MohsinHijazee wrote: > > Hi! > > I have a new class which needs to reuse the code in two classes. > > But I can only derive it from one class. How should I go about it then? > > Use mixins, by defining modules Posting as a beginner, I wonder if something like this (inheriting from one class while incorporating an instance of the other) might work: class SiblingClass < ParentClass1 def initialize @reuseParent2 = ParentClass2.new() end def method_missing(methodName,*args) @reuseParent2.send(methodName,*args) end end -- Morel