Whatever message this page gives is out now! Go check it out!

StructUpdate

Last update:
May 18, 2026

Description

Updates a key with a value.

Returns

Returns the updated struct; if the structure does not exist, ColdFusion throws an error.

Category

Syntax

StructUpdate(structure, key, value)

See also

Structure functionsModifying a ColdFusion XML object in the Developing ColdFusion Applications

History

ColdFusion (2018 release): Returns the updated struct.
ColdFusion MX: Changed behavior: this function can be used on XML objects.

Parameters

Parameter
Description
structure
Structure to update.
key
Key, the value of which to update.
value
New value.

Example

<cfscript>
       myStruct=StructNew();
       myStruct={a=1,b=2,c=3,d=4,e=5};
       WriteOutput("Before struct update:");
       WriteDump(myStruct);
       StructUpdate(myStruct,"e",6); // Update key-value pair e-5 to e-6
       WriteOutput("After struct update:");
       WriteDump(myStruct);
</cfscript>

Output

Figure: structupdate output
structupdate output

Using member function

<cfscript>
       myStruct={a=1,b=2,c=3,d=4,e=5};
       myStruct.update("e",6);
       WriteDump(myStruct);
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page