Inserts a key-value pair into a structure.
structInsert(structure, key, value [, allowoverwrite])
→ returns boolean
false
true
false
Inserts a new key/value into the structure
map = {
"hair" : "brown",
"eyes" : "green"
};
structInsert(map, "lips", "red");
writeOutput(structKeyList(map));
Expected Result: eyes,lips,hair
Throws exception when you try to add a duplicate key, when allowoverwrite parameter is false.
map = {
"hair" : "brown",
"eyes" : "green"
};
try {structInsert(map, "hair", "red", false);}
catch(any ex) {writeOutput("error!");}
Expected Result: error!
Signup for cfbreak
to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.