Yes, but in your example, isSuperUser will probably only contain boolean
values.

query.recordCount will not contain "typical" boolean values.

In the case of query.recordCount, FALSE=[0] and TRUE=[everything else].

I've done it both ways.  "query.recordCount gt 0" tends to add a bit
more explanation as to the intent of the code.  However, it does add a
few keystrokes.

Mike

-----Original Message-----
From: Justin Scott [mailto:[email protected]] 
Sent: Friday, January 09, 2009 2:19 PM
To: cf-talk
Subject: Re: anybody see this before?

Barney Boisvert wrote:
> Don't do that.  What's happening is that the number
> (isthere.recordcount) is being implicitly converted to a boolean for 
> the CFIF to process.  Implicit conversion where the destination type 
> is something besides String is almost always the devil, end even if 
> it's String it's still the devil sometimes.

Personally, I've always seen the implicit type conversions as a feature
of CFML, not a thing to be avoided.  As the programmer, if you're
certain a variable will contain data that the language can convert with
predictable results, then there is no reason not to use it aside from
personal preference.

Take, for example, pulling a bit value from a database.  Let's use
isSuperUser as an example in a membership system.  Take the following,
should it be...

<cfif userInfo.isSuperUser>
OR
<cfif userInfo.isSuperUser is 1>

Is ColdFusion seeing that as a boolean because it came from the database
as a bit field, or as an integer because the database returned a value
of 1 (assuming SQL Server here)?  In ColdFusion, it doesn't matter and
you will get the same results either way without any fuss.


-Justin Scott

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:317674
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to