How should I use clone() to prevent objects overwriting
Posted: 02 Sep 2018, 12:01
Here's a very simplified example of a piece of code that I use
Clone() doesn't seem to work in this example. And still fills both objects with the same variable. How should I solve this issue?
Code: Select all
value := {B:{C:[]}}
object1 := {A:{}}
object2 := {A:{}}
object1["A"] := value.clone()
object2["A"] := value.clone()
object1["A"]["B"]["C"] := object1["A"]["B"]["C"].clone()
object2["A"]["B"]["C"] := object2["A"]["B"]["C"].clone()
object1["A"]["B"]["C"].push("A")
msgbox % object1["A"]["B"]["C"][1] . ", " . object2["A"]["B"]["C"][1] ; < Both objects return A