Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Normally you create a function using cfscript like:

<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 you can do it with tags:

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

But I don't want to have to rewrite this large function thats already written in cfscript.

like image 363
Ryan Stille Avatar asked Dec 08 '22 09:12

Ryan Stille


1 Answers

Not in ColdFusion 8. It was added in CF9, though.

You don't 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";
}
like image 81
Peter Boughton Avatar answered May 29 '23 04:05

Peter Boughton