Jim Flannery wrote:
Thursday, October 26, 2006, 4:42:47 PM, one spoke:
JC> structCopy: Copies a structure. Copies top-level keys, values, and
JC> arrays in the structure by value; copies nested structures by
JC> reference.
JC> Looks like the structCopy() is doing what it's supposed to do to me
JC> since the url.test isn't nested and is a simple value.
Why then would deleting the copy of the top-level key which is a simple
value delete the original of the key (expected behavior if it were
copied *by reference*)?
(n.b. Sammy, if this is a problem you likely want to be using
Duplicate(), which was introduced to work around exactly this
Jekyll/Hyde behavior.)
Actually, I said in the last post I was getting the same behavior in
duplicate, but I was wrong. I wasn't doing the /exact/ same thing, but
I was doing something I would still expect to work. Here it is:
<cfset form.test = 1>
<cfset tempform = duplicate(form)>
<cfset structdelete(form, "test")>
<cfset form=duplicate(tempform)>
<cfoutput>
In Form: #structkeyexists(form,"test")#<br/>
In Temp Form: #structkeyexists(tempform,"test")#
</cfoutput>
You are subscribed to cfcdev. To unsubscribe, please follow the instructions at
http://www.cfczone.org/listserv.cfm
CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]