| CFML Reference
|
|
ColdFusion Functions
|
Duplicate
Description
Returns a clone, also known as a deep copy, of a variable. Unlike StructCopy, Duplicate copies the variable, so there is no reference to the original variable.
Category
Structure functions
Syntax
Duplicate(variable_name)
See also
StructCopy
Parameters
| Parameter |
Description |
variable_name
|
The name of a variable to duplicate
|
Usage
This function is useful in duplicating complex structures, including nested structures and queries.
|
Note You cannot duplicate a COM, CORBA or JAVA object returned from the cfobject tag or the CreateObject function. If an element in an array or a field of a structure is a COM, CORBA, or JAVA object, you cannot duplicate the array or structure. If you try to duplicate an object of this sort, an exception is thrown.
|
Example <!--- This example shows the use of Duplicate --->
<html>
<head>
<title>Duplicate Example</title>
</head>
<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>
</body>
</html>
|
Copyright © 2001, Macromedia Inc. All rights reserved. |
|
|