DUPLICATE |
Description Returns a clone, also known as a deep copy, of a variable. There is no reference to the original variable.
Returns A clone of a variable.
Category Structure functions, System functions
Function syntax
    Duplicate(variable_name)
See also StructCopy, other Structure functions; "Modifying a ColdFusion XML object" in Chapter 35, "Using XML and WDDX," in ColdFusion MX Developer's Guide
History ColdFusion MX: Changed behavior: this function can be used on XML objects.
Parameters
Usage Use this function to duplicate complex structures, such as nested structures and queries.
Note: | The Duplicate function throws an exception if you attempt to duplicate a CFC.
Note: | With this function, you cannot duplicate a COM, CORBA, or JAVA object returned from the cfobject tag or the CreateObject function. If an array element or structure field is a COM, CORBA, or JAVA object, you cannot duplicate the array or structure.
Example
    <h3>Duplicate Example</h3>
    <cfset s1 = StructNew()>
    <cfset s1.nested = StructNew()>
    <cfset s1.nested.item = "original">
    <cfset copy = StructCopy(s1)>
    <cfset clone = Duplicate(s1)>
    <!--- modify the original --->
    <cfset s1.nested.item = "modified">
    <cfoutput>
    <p>The copy contains the modified value: #copy.nested.item#</p>
    <p>The duplicate contains the original value: #clone.nested.item#</p>
    </cfoutput>

VARIABLE_NAME |

Name of a variable to duplicate