structDelete

Removes an element from a structure.

structDelete(structure, key [, indicateNotExisting]) → returns boolean

Member Function Syntax

someStruct.delete(key)

structDelete Argument Reference

structure string
Required

Structure or a variable that contains one. Contains element
to remove

key string
Required

Element to remove

indicateNotExisting boolean
Default: false

When true this function will return true only if the key that was deleted existed. When false (default) this function will return true if the key is successfully removed.

Examples sample code invoking the structDelete function

Creates a struct then removes a key

someStruct = {a=1,b=2};
structDelete(someStruct, "a");

writeDump(someStruct);

Expected Result: true

CF 11+ Lucee 4.5+ Invoking the delete function on a struct is the same as running structDelete.

someStruct = {a=1, b=2};
someStruct.delete('a');

writeDump(someStruct);

Expected Result: true


Fork me on GitHub