What would be the correct 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>
It doesn't make much of a difference. There is no right or wrong here. When the return type has been set to void
the function can't return anything.
You can use <cfreturn />
within your code to prematurely exit your function, if you need to. Putting it at the end won't do anything, because the function will return nothing whether you put it there or not. But it also doesn't hurt to put it there and some people might think it more clear if it's there to state "nothing is been returned here".
I think it's a matter of personal preference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With