StructCopy
Creates a shallow copy of a struct.
Copies top-level keys, values, and arrays in the structure by value; copies nested structures by reference.
Method Signature
StructCopy(struct=[structloose])Arguments
Argument
Type
Required
Description
Default
struct
struct
true
The struct to copy
Examples
Copy a structure and change it. Original structure stays unchanged
myStruct = {
"a" : 1,
"b" : 2,
"c" : 3
};
myNewStruct = structCopy( myStruct );
myNewStruct.B = 5;
myNewStruct[ "d" ] = 4;
structDelete( myNewStruct, "c" );
writeOutput( structKeyList( myStruct ) & " → " & structKeyList( myNewStruct ) );
Result: b,a,c → b,a,d
Additional Examples
Related
Last updated
Was this helpful?
