By default, ColdFusion passes simple functions (such as numeric, string, and GUIDs) by value in the function. I would like to pass a simple type by reference.
Currently, I am transferring a simple value to a structure (they are passed by reference). This solves my problem, but it is very ugly:
<cffunction name="TheFunctionName">
<cfargument name="OutVariable" type="struct">
<cfset OutVariable.ID = 5>
</cffunction>
<cfset OutVariable=StructNew()>
<cfset TheFunctionName(OutVariable)>
<cfoutput>#OutVariable.ID#</cfoutput>
I would prefer something like this:
<cffunction name="TheFunctionName">
<cfargument name="OutVariable" passbyref="true">
<cfset OutVariable = 5>
</cffunction>
<cfset TheFunctionName(OutVariable)>
<cfoutput>#OutVariable#</cfoutput>
source
share