Should I use cfreturn in function with returntype void

What will be the right way? I think both work, but I wonder if there are benefits from one to the other.

<CFFUNCTION name="setSomething" access="public" output="no" returntype="void"> <CFSET ... /> </CFFUNCTION> 

OR

 <CFFUNCTION name="setSomething" access="public" output="no" returntype="void"> <CFSET ... /> <CFRETURN /> </CFFUNCTION> 
+7
source share
1 answer

It does not really matter. There is no right or wrong. If the return type is set to void , the function cannot return anything.

You can use <cfreturn /> in your code to exit your function prematurely if you need to. Putting it at the end will do nothing, because the function will not return anything, whether you place it there or not. But this does not hurt to put him there, and some people might think that it is more clear if it was said there that "nothing returns here."

I think this is a matter of personal preference.

+20
source

All Articles