diffrance b/w StructCopy() and Duplicate()

  • StructCopy(): Creates a clone of the structure by reference (clones top level keys and values by value and nested structures by reference)

  • Duplicate(): Creates a clone of any type of objects (that can be a structure) by value.
Therefore, We need to be very very careful while creating a clone of a structure by using StructCopy(), because any change to the cloned structure will be reflected in master structure (as it is cloned by reference). This might create side effects in the program.
 
When we clone by Duplicate(), any changes with the cloned structure will NOT be reflected in the master structure (as it is cloned by value). So it will not have any side effects in the program.

Comments

Popular posts from this blog

What is the difference between asynchronous and synchronous execution?

Yahoo accepting requests for inactive email IDs

Badtameez Dil Lyrics--Yeh Jawaani Hai Deewani Song