StructInsert

Inserts a key-value pair into a structure.

StructInsert( struct, key, value [, allowoverwrite ] )

Returns: Boolean

Argument Description
struct
struct, required

Structure to contain the new key-value pair.

Alias: structure, object

key
string, required

Key that contains the inserted value.

value
any, required

Value to add.

allowoverwrite
boolean, optional

Whether to allow overwriting a key. Default: False.

Alias: overwrite

Examples

Member Function

animals = {
	cow: "moo",
	pig: "oink"
};
// Show current animals
Dump(
	label: "Current animals",
	var: animals
);
// Insert cat into animals
animals.insert("cat", "meow");
// Show animals, now includes cat
Dump(
	label: "Animals with cat added",
	var: animals
);

Non-Member Function

animals = {
	cow: "moo",
	pig: "oink"
};
// Show current animals
Dump(
	label: "Current animals",
	var: animals
);
// Insert cat into animals
StructInsert(animals, "cat", "meow");
// Show animals, now includes cat
Dump(
	label: "Animals with cat added",
	var: animals
);

See also