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

Structure to copy

Alias: structure, object

Examples

Non-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