ColdFusion: Is it safe to leave out the variables keyword in a CFC? -


in coldfusion component (cfc), necessary use qualified names variables-scoped variables?

am going myself trouble if change this:

<cfcomponent>     <cfset variables.foo = "a private instance variable">      <cffunction name = "dosomething">         <cfset var bar = "a function local variable">         <cfreturn "i have #variables.foo# , #bar#.">     </cffunction> </cfcomponent> 

to this?

<cfcomponent>     <cfset foo = "a private instance variable">      <cffunction name = "dosomething">         <cfset var bar = "a function local variable">         <cfreturn "i have #foo# , #bar#.">     </cffunction> </cfcomponent> 

it won't matter specify "variables" when create variable, because foo placed in variables scope default; matter when access variable.

<cfcomponent>     <cfset foo = "a private instance variable">      <cffunction name="dosomething">         <cfargument name="foo" required="yes"/>         <cfset var bar = "a function local variable">         <cfreturn "i have #foo# , #bar#.">     </cffunction>      <cffunction name="doanotherthing">         <cfargument name="foo" required="yes"/>         <cfset var bar = "a function local variable">         <cfreturn "i have #variables.foo# , #bar#.">     </cffunction>  </cfcomponent> 

dosomething("args") returns "i have args , function local variable"

doanotherthing("args") returns "i have a private instance of variable , function local variable."


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -