Cool. That's I was looking for!
Thanks a lot
Rudi
 
 


Bert Freudenberg <bert@impara.de> wrote:

Am 31.07.2005 um 21:35 schrieb Rudi Bichler:

> Hi,
>
> I need some kind of copyTo: functionality, which copies a complete
> object (i.e. all instance variables) to another object. I need this
> to "convert" an object of class A into an object of a subclass of
> A. Something like:
>
> Object subclass: #MyClass
> instanceVariableNames: 'var1 var2' ...
>
> MyClass subclass: #MySubcl
> instanceVariableNames: 'var3' ...
>
> MySubcl class >> newCopyFrom: original
> "create an object of class MySubcl with is - as MyClass - identical
> to original"
>
> An example of such a functionality is FormCanvas asBalloonCanvas.
> This method is implemented by creating a BalloonCanvas and
> initializing it "by hand". I am looking for a generic way -
> something like copy in Object. Any idea?

Looking into the #copy method in Object you'll notice it calls
#shallowCopy, which implements a generic copy of all instance
variables - take a look!

- Bert -



Start your day with Yahoo! - make it your home page