Question

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.

Was it helpful?

Solution

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";
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top