StructInsert()
Inserts a key-value pair into a structure.
StructInsert( struct=struct, key=string, value=any, allowOverwrite=boolean );
Returns: Boolean
| Argument | Description |
|---|---|
|
struct
struct,
required
|
edit
Structure to contain the new key-value pair. Alias: structure, object |
|
key
string,
required
|
edit
Key that contains the inserted value. |
|
value
any,
required
|
edit
Value to add. |
|
allowOverwrite
boolean,
optional
|
edit
Whether to allow overwriting a key. Default: False. Alias: overwrite |
Examples
editNon-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
- Structures
- Collections
- struct.insert()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)