Assuming that there were no implicit coersions in your code, I would agree.
However, there are.

> <CFSET a = 20>
> <CFIF a>a is true<CFELSE>a is not true</CFIF><BR>
Is a a true value?
> <CFIF a EQ "yes">a is true<CFELSE>a is not true</CFIF><BR>
Is a equal to the string 'yes'
> <CFIF a EQ true>a is true<CFELSE>a is not true</CFIF><BR>
> <CFIF a IS true>a is true<CFELSE>a is not true</CFIF><BR>
Is a equal to the boolean true?
> <CFIF a EQ "no">a is false<CFELSE>a is not false</CFIF><BR>
Is a equal to the string 'no'
> <CFIF a EQ false>a is false<CFELSE>a is not false</CFIF><BR>
> <CFIF a IS false>a is false<CFELSE>a is not false</CFIF><BR>
Is a equal to the boolean false

Why should 'a' (a number) be treated as equal to the boolean true, if it's
not treated as equal to the string 'yes', even though both true and 'yes'
will be treated as true in a boolean context?

You may as well add these in there too as proof that numbers aren't boolean:

<cfset a = 20 />
<cfset b = 15 />
<cfif a>a is true<cfelse>a is not true</cfif><br />
<cfif b>a is true<cfelse>a is not true</cfif><br />
<cfif a EQ b>a is true<cfelse>a is not true</cfif><br />
<cfif a IS b>a is true<cfelse>a is not true</cfif><br />

> -----Original Message-----
> From: Claude Schneegans [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 20, 2004 4:13 PM
> To: CF-Talk
> Subject: Re: Is it a bug or not a bug?
>
> >>how can you argue that 20 is not a valid result from a
> boolean _expression_?
>
> Take this code:
>
> <CFSET a = 20>
> <CFIF a>a is true<CFELSE>a is not true</CFIF><BR>
> <CFIF a EQ "yes">a is true<CFELSE>a is not true</CFIF><BR>
> <CFIF a EQ true>a is true<CFELSE>a is not true</CFIF><BR>
> <CFIF a IS true>a is true<CFELSE>a is not true</CFIF><BR>
> <CFIF a EQ "no">a is false<CFELSE>a is not false</CFIF><BR>
> <CFIF a EQ false>a is false<CFELSE>a is not false</CFIF><BR>
> <CFIF a IS false>a is false<CFELSE>a is not false</CFIF><BR>
>
> it shows:
>
> a is true
> a is not true
> a is not true
> a is not true
> a is not false
> a is not false
> a is not false
>
> It shows that a is considered as true if taken isolated, but
> it is neither EQ to "yes", neither to true, and neither IS true...
> As a matter of fact, a is neither true nor false.
>
> Is this normal? C'mon, there is something wrong here.
> What's the difference?
> The difference is that in <CFIF a>, a must be converted to a
> boolean value in order for the _expression_ to be evaluated,
> and this gives true because not 0.
> BUT in all other expressions, a is not converted, it is just
> compared for its true value to another value, and definitely,
> its value is not considered as true by CF.
>
> This clearly shows that 20 is CONVETED to true, but IS NOT
> equal to true.
> Now, if 20 is neither EQ true neither EQ false, the only
> possible conclusion is that 20 is NOT a boolean value.
> And if 20 is NOT a boolean value, in no way it should be the
> result of a boolean _expression_.
>
> QED... ;-)
>
> --
> _______________________________________
> See some cool custom tags here:
> http://www.contentbox.com/claude/customtags/tagstore.cfm
> Please send any spam to this address: [EMAIL PROTECTED]
> Thanks.
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to