From: Matthias Veit Date: 2002-07-16T07:29:28+09:00 Subject: Re: cut & paste for code >>>> HEF == "Hal E. Fulton" wrote: HEF> Move the methods into a module M. HEF> Include M in both A and B. HEF> HEF> No duplication of code that way, and HEF> no inheritance. HEF> HEF> How is that? HEF> HEF> There is probably an esoteric solution that HEF> will literally do exactly what you wanted... HEF> but I can't think of a way to do it yet. I really like this solution, but I think my problem is even more esoteric. Following situation: ------------------------------------------- module R class A end class B def a return A.new end end end module T class A copy_from(R::A) #magic copy end class B copy_from(R::B) #magic copy end end -------------------------------------------- What i want to achieve is described best with "copy inheritance" - no real inheritance, more like copy the source code from one class to another (as easy as in every editor). The call T::B.new.a shall return a T::A not an R::A. With the module approach it looks like: -------------------------------------------- module R class A end module B_ def a return A.new new end class B include B_ end end module T class A end class B include R::B_ end end -------------------------------------------- Because the module B_ gets its binding in context of R, A.new means R::A.new. Thus the include in T::B ought to do something like rebind after include. Do you have any idea? Best regards, Matthias __________________________________________________ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.comm