Skip to main content
John_Allred
Inspiring
Jun 13, 2021 3:19 PM UTC
Answered

Question on boolean format

Adobe tells me:

"Boolean values Use True, Yes, or 1 for  true  and False, No, or 0 for false. Boolean values are not case sensitive."

 

String values are enclosed in double quotes.

 

When used in code, are boolean values enclosed in quotes like strings are? Or are they used, plain?

For example, should the following be written as:

<cfif session.isloggedin is "1">

—or—

<cfif session.isloggedin is true>

 

Thanks!

This topic is closed to new replies. Start a new post to keep the conversation going.
George____
George____Correct answer
Inspiring
Jun 14, 2021 10:42 AM UTC

Yes, the booleans enclosed in quotes are still treated as booleans.  Coldfusion will convert automatically, so it doesn't matter which you use.   My preference would be

<cfif session.isloggedin>

 

That will evaluate to true regardless of whether it's true, "true", "yes" or any non-zero number.

It will evaluate to false if it's false, "false", "no" or zero.

 

2 replies

George____
George____Correct answer
Inspiring
Jun 14, 2021 10:42 AM UTC

Yes, the booleans enclosed in quotes are still treated as booleans.  Coldfusion will convert automatically, so it doesn't matter which you use.   My preference would be

<cfif session.isloggedin>

 

That will evaluate to true regardless of whether it's true, "true", "yes" or any non-zero number.

It will evaluate to false if it's false, "false", "no" or zero.

 

Translate
John_Allred
Inspiring
Jun 14, 2021 1:34 PM UTC

Thanks, George.

Translate