On Sun, Nov 20, 2011 at 7:26 PM, Alan Holden <[email protected]> wrote:

> **
> Doesn't CF do numeric to Boolean conversion as a convenience?
>

Yep.


>
> IOW, CF will automatically cast resulting 0 as FALSE and >0 as TRUE for
> us, when used in an evaluation.
>

Right, anything other than 0 (including negative numbers) is true in CFML.
0 is false.


>
> Now I wonder which one takes more cycles in your code... explicitly adding
> the "GT 0" or just letting CF figure it out internally.
>

Honestly it's probably the same or the difference would be so negligible as
to be irrelevant.

To me I always make decisions around stuff like this based on the impact on
the readability of the code. I tend towards explicitly doing things like
<cfif Len(foo) gt 0> as opposed to leaving the gt 0 off simply because Len
doesn't return a boolean, it returns a number. But it'll certainly work
either way, provided you're aware of the fact that negative numbers
translate to true. Wouldn't happen in this particular case of course since
the Len can't be < 0, but I've seen that trip people up, hence why I prefer
the more explicit approach.

-- 
Matthew Woodward
[email protected]
http://blog.mattwoodward.com
identi.ca / Twitter: @mpwoodward

Please do not send me proprietary file formats such as Word, PowerPoint,
etc. as attachments.
http://www.gnu.org/philosophy/no-word-attachments.html

-- 
online documentation: http://openbd.org/manual/
   google+ hints/tips: https://plus.google.com/115990347459711259462
     http://groups.google.com/group/openbd?hl=en

Reply via email to