4.3 Copied assignment of arrays and objects

If the right side of an assignment statement has object variables, the entire values of the variables will be copied to the variables of the left side. When an array or an object includes sub-arrays and sub-objects in a complex manner as element values, such inclusion structures will be copied, which is called a deep copy.

0001.job

var my_obj = [ x:5, y:0, z:0 ]

my_obj.y=[ [10, 20], ["abc", true] ]

my_obj.z={ a:7, b:8 }

var your_obj=my_obj # deep copy

print your_obj.y[0]

Result

[10, 20]

Last updated

Was this helpful?