
ColdFusion
Results 1 - 10 of around 2 in coldfusionSometimes it's the little things
I've been doing this ColdFusion thing for, as of today, a month short of 7 years. I'm not often suprised by CF but this had me thinking long and hard for embarrassing longer than I would like to admit.
Now, without looking too far down the page, what would you expect from the following:
<cfset VARIABLES.someVar = "">
<cfif someConditionThatMightBeTrue>
<cfset VARIABLES.someVar = CreateObject("component", "path.to.my.cfc")>
</cfif>
<cfif VARIABLES.someVar EQ "">
We haven't created the object yet.
<cfelse>
We have an object!
</cfif>
Me? I was thinking it would work as I wanted. Check to see if VARIABLES.someVar was an empty string, if not, the object hadn't been created.
Why then did it take me so long to see that comparing a string to an object, once it had been created, with EQ was the reason things weren't working as I expected?
You'd think the following error would have speeded up the debugging process also!
Complex object types cannot be converted to simple values.
Anyway, the point is. Use IsSimpleValue() rather than EQ.
Comments
Haha! My second favourite willy! :OD
Or use isObject(). :) The one that actually got me hacked off is this... if you try isXmlNode(StructNew()) instead of simply returning false, like it should, it throws an error to let you know that the structure isn't XML... which presumably is what you wanted to know in the first place. :P But rather than just returning yes or no, it gets its shorts in a knot because you asked the question.
Question: Is the Eiffel tower a dog?
Answer: I can't answer that because the Eiffel tower isn't an animal!
uhhh... you just did answer it.
Ah, good point on the IsObject() front!
Very well done! Even thou you forced me to read it!