As per the CF documentation:
ARGUMENT scope takes precedence over VARIABLE scope
I tried this code.
<cfset fun(25)>
<cffunction name="fun">
<cfargument name="roll" >
<cfset roll = 60>
<cfdump var="#roll#">
</cffunction>
I expect the output to be 25, but its 60. I cannot understand why the ARGUMENT scope
is not taking precedence over VARIABLE scope? Or am I missing something?
You've just updated arguments.roll to 60. If you want a local function variable that's not going to be overwritten by the argument of the same name, assign it to the local scope:
<cfset local.roll = 60>
<cfdump var="#roll#"> // 25, as arguments scope takes precedence
<cfdump var="#local.roll#"> // 60
<cfdump var="#arguments#"> // 25
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With