specific true and false values are varied, but they are still equivalent.
This block is as well:
<cfoutput>
#1 and 100#<br />
#false or 10#<br />
#false or 0#<br />
#0 and false#<br />
</cfoutput>
If you want a boolean value returned, you can use yesNoForamt(), though that
will return 'yes' or 'no'. If you really want true or false returned, use
this UDF:
<cfscript>
function booleanFormat(expr) {
if (expr)
return true;
return false;
}
</cfscript>
Using that UDF, here's a final block that is equivalent to the first three,
but also yields the correct string representations of the values:
<cfoutput>
#booleanFormat(1 and 100)#<br />
#booleanFormat(false or 10)#<br />
#booleanFormat(false or 0)#<br />
#booleanFormat(0 and false)#<br />
</cfoutput>
Cheers,
barneyb
> -----Original Message-----
> From: Bryan F. Hogan [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 20, 2004 1:46 PM
> To: CF-Talk
> Subject: Re: Is it a bug or not a bug?
>
> Run this:
>
> <cfif true and (4*5)>true<cfelse>false</cfif><br>
> <cfif (4*5) and true>true<cfelse>false</cfif><br>
> <cfif false and (4*5)>true<cfelse>false</cfif><br>
> <cfif (4*5) and false>true<cfelse>false</cfif><br>
> <br>
> <cfoutput>#true and (4*5)#</cfoutput><br>
> <cfoutput>#(4*5) and true#</cfoutput><br>
> <cfoutput>#false and (4*5)#</cfoutput><br>
> <cfoutput>#(4*5) and false#</cfoutput><br>
>
> Barney Boisvert wrote:
>
> > This is not a bug, it's just part of using a loosely typed language.
> > Non-zero values are true, and zero is false. A
> short-circuited boolean
> > evaluation returns the value of the last _expression_ that is
> evaluated.
> >
> > Note, that whether the first test returns 'true' or '20',
> both are true
> > values, so it won't affect anything. You can use 20 any
> place you use true
> > and it will behave the same way.
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

