structCopy

Copies a structure. Copies top-level keys, values, and arrays
in the structure by value; copies nested structures by
reference.

structCopy(structure) → returns struct

Argument Reference

structure struct
Required

Structure to copy

Examples
Sample code invoking the structCopy function

myStruct = {
    'a': 1,
    'b': 2,
    'c': 3
};
myNewStruct = structCopy(myStruct);
myNewStruct.b = 5;
myNewStruct['d'] = 4;
structDelete(myNewStruct,'c');
writeOutput(structKeyList(myStruct)&' → '&structKeyList(myNewStruct));

Expected Result: b,a,c → b,a,d

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub