View comments | RSS feed

Duplicate

Description

Returns a clone, also known as a deep copy, of a variable. There is no reference to the original variable.

Return value

A clone of a variable.

Category

Structure functions, System functions

Syntax

Duplicate(variable_name)

See also

StructCopy, other Structure functions

History

New in ColdFusion MX: this function can be used on XML objects.

Parameters

Parameter Description
variable_name
Name of a variable to duplicate

Usage

Use this function to duplicate complex structures, such as nested structures and queries.

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>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


spage-mm said on Nov 20, 2002 at 4:55 AM :
If you try to duplicate arguments scope in a function, you get null pointer error at coldfusion.util.FastHashtable.find(Unknown Source). I guess scopes don't work like exactly like structures.
hlichtin said on Mar 13, 2003 at 10:45 AM :
The inability to duplicate the arguments scope has been entered as a ColdFusion bug.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt174.htm