[DGD] Variable issue

Par Winzell zell at skotos.net
Tue Apr 9 14:41:15 CEST 2002


> I have a problem with one variable (a mapping) being
> affected when I change another variable in another
> object, which I have assigned the value of the first
> mapping.  I am a beginner, so be nice!
> 
> This is what I mean:
> 
> In obj1 I have a mapping map1
> In obj2 I have a mapping map2
> 
> In obj2 I do: map2 = obj1->query_map1(); /* which
> returns map1 */
> 
> Now, when I manipulate map2, I will end up with having
> map1 changed aswell.  I want to avoid this.  What
> should I do?


You can do

   map2 = obj1->query_map1()[..];

to do a surface-level copy. For a deeper copy you'll need to recurse through 
the data structure. Source code for such a routine was posted to this list a 
while back -- check the archives.

Zell

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list