"Komag" wrote: I realize this is years old, but I just can't believe this isn't an official Function by now! I use TheEndless' ShallowCopy() Function now in several key places to copy Associative Arrays of various depths where I don't want references but actual new copies.
You want a deep copy of (acyclic) structure of simple types/arrays/AAs, just use
newCopy = parseJson(formatJson(myData))
You want other/reference types in the mix, use variation of the above `shallowCopy`. Deep copy should be hard, when you do it you should know it is expensive. To that, some "magic" function will be misleading you in thinking it's easy/cheap, when behind the scene it is expensive. I see this confusion all the time with the RSG field dot-access, then complains "why is my code/Roku slow".
Hmm, I'm not experienced in programming and haven't seen enough to judge the wisdom of making deep copy easy or hard. I do try to use it sparingly, at times when performance isn't as important (such as when loading the game - as opposed to during game-play).