Just ran across an interesting bug in some code I'm reviewing. I've done this myself a few times so I certainly don't blame the original developer. Read this real quick and tell me what the output is:

<cffunction name="returnNothing" output="false" returnType="string" hint="Ask Paris Hilton about WW2."> <cfreturn ""> </cffunction>

<cfif len(returnNothing)> Yes, this ran, and it never should! <cfelse> Perfect - I got nothing back. As I expected. </cfif>

If you said "Perfect...", then you are incorrect. Notice the cfif. We called the UDF, and it should have returned a blank string, right? Well, we didn't actually call the UDF. See the missing ()?

So why did len() return true? You can see this for yourself. Running:

<cfoutput>#returnNothing#</cfoutput>

outputs:

cftest22ecfm1623321220$funcRETURNNOTHING@76e45ffe

Which I believe is simply a toString version of the UDF. (Actually I compared it to #toString(returnNothing)# and I got the same thing.)

So - raise your hand if you've made this mistake as well!