In ColdFusion 8, can you declare a function as private using cfscript?

Usually you create a function using cfscript, for example:

<cfscript> function foo() { return "bar"; } </cfscript> 

Is there a way to declare this as a private function, available only to other methods inside the same cfc?

I know that you can do this with tags:

 <cffunction name="foo" access="private"> <cfreturn "bar"> </cffunction> 

But I do not want to rewrite this big function which is already written in cfscript.

+4
source share
1 answer

Not in ColdFusion 8. However, it was added in CF9.

You do not need to rewrite the whole function, you can do this:

 <cffunction name="foo" returntype="string" output="false" access="private"> <cfscript> return "bar"; </cfscript> </cffunction> 

If you have access to CF9, the new syntax is:

 private string function foo() output="false" { return "bar"; } 
+15
source

Source: https://habr.com/ru/post/1276832/


All Articles