G'day
This is an inconsistency with CF that Railo shares with BD.  I'm not
sure why my tests show this up on Railo but not BD though... I need to
look at that... hmmm...

Anyway, some code:

<!--- Numbers.cfc --->
<cfcomponent>

        <cfset variables.aNumbers = listToArray("tahi,rua,toru")>

        <cffunction name="getNumbers" returntype="array">
                <cfreturn variables.aNumbers>
        </cffunction>

</cfcomponent>

<!--- caller.cfm --->
<cfset o = createObject("component", "Numbers")>

<cfset aNumbers1 = o.getNumbers()>
<cfset arrayAppend(aNumbers1, "wha")>
<cfdump var="#aNumbers1#">

<cfset aNumbers2 = o.getNumbers()>
<cfset arrayAppend(aNumbers2, "wha")>
<cfdump var="#aNumbers2#">

Now, because - I guess - CF copies the array when it's assigned to a
new variable, I just end up with "tahi, rua, toru, wha" in the second
dump (which is what I'd expect).  On BD (Open & .NET), and Railo, I
guess it's just referencing the one array throughout, so I get "tahi,
rua, toru, wha, wha".

I realise the way CF handles arrays is a bit of an idiosyncracy cf
other complex data types, but given the precedent is set, should not
the other engines follow suit?

[...]

--
Adam

-- 
Open BlueDragon Public Mailing List
 http://www.openbluedragon.org/   http://twitter.com/OpenBlueDragon
 official manual: http://www.openbluedragon.org/manual/
 Ready2Run CFML http://www.openbluedragon.org/openbdjam/

 mailing list - http://groups.google.com/group/openbd?hl=en

Reply via email to