StructCopy()
Copies a structure. Copies top-level keys, values, and arrays in the structure by value; copies nested structures by reference.
StructCopy( struct=struct );
Returns: object
| Argument | Description |
|---|---|
|
struct
struct,
required
|
edit
Structure to copy Alias: structure, object |
Examples
editNon-Member Function
animals = {
cow: "moo",
pig: "oink"
};
// Show current animals
Dump(
label: "Current animals",
var: animals
);
// Copy animals struct to farm
farm = StructCopy(animals);
// Show farm, looks like animals
Dump(
label: "Farm after StructCopy()",
var: farm
);
// Add another animal. Will not affect farm.
StructAppend(animals, {
cat: "meow"
});
// Show animals, now includes cat
Dump(
label: "Animals with cat added",
var: animals
);
// Show farm, does not have cat
Dump(
label: "Farm copied from animals before cat was added",
var: farm
);
See also
- Structures
- struct.copy()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)