----- Original Message ----- 
From: "Matthias Veit" <matthias_veit / yahoo.de>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Monday, July 15, 2002 1:55 PM
Subject: cut & paste for code


> I want to copy code from one class to another at runtime.

I'm thinking about this.

The most elegant solution I can 
come up with right now is:

Move the methods into a module M.
Include M in both A and B.

No duplication of code that way, and
no inheritance.

How is that?

There is probably an esoteric solution that 
will literally do exactly what you wanted...
but I can't think of a way to do it yet.

I started thinking along the lines of 
B = A.dup, but of course that simply replaces
the old B (wiping out inheritance, etc.).

Probably Guy Decoux could do it in a single
line of code consisting only of punctuation
marks. :)

Hal Fulton