danmurphy
02/11/2022, 11:33 PMbooleanFormat() works?
https://trycf.com/gist/e63f40983cb86a0b178bcc1ff4e8215f/lucee5?theme=monokaiAdam Cameron
'False', passes it to booleanFormat which returns a string "false" . You use that as the operand for the ! operator which takes a boolean, so Lucee converts "false" to a boolean (false) and then evaluates the expression which is !false which is true .danmurphy
02/11/2022, 11:50 PM! operator is the thing that actually is able to turn it into an actual boolean. Got it.ageax
02/11/2022, 11:51 PMBooleanFormat so I was suprised it returned a string 😆danmurphy
02/11/2022, 11:51 PMageax
02/11/2022, 11:52 PMageax
02/11/2022, 11:53 PMdanmurphy
02/12/2022, 12:14 AM'False' is a string but 'False' EQ false returns an actual boolean just fine. I was trying to avoid the whole myVar EQ false thing (which I now learned booleanFormat() will not get me closer to doing) but oh well.Adam Cameron
myVar EQ false, then you can go NOT myVar or !myVar. You don't need to do anything else.danmurphy
02/12/2022, 12:16 AM!myVar but I’ll check it out again.Adam Cameron
Adam Cameron
Adam Cameron
"some string that ain't boolean" eq false will be doing a string comparison, not a boolean checkAdam Cameron
danmurphy
02/12/2022, 12:22 AMdanmurphy
02/12/2022, 12:29 AM!myVar since I have a string of 'False'.
https://trycf.com/gist/718f17b9b0939c9893d0f45b5e1bb05f/lucee5?theme=monokaidswitzer
02/15/2022, 2:23 PMbooleanFormat() was designed to help get boolean-like variables to something that JavaScript will understand as a boolean.
For example, booleanFormat("Yes") returns true, which could be used safely in JSON/JavaScript.Adam Cameron
dswitzer
02/16/2022, 12:58 PMAdam Cameron
<cfoutput>
<cfset b = isValid("string", "my string")>
#b.getClass().getName()#<br>
#b#<br>
#toString(b)#<br>
#b.toString()#<br>
<hr>
<cfset b = true>
#b.getClass().getName()#<br>
#b#<br>
#toString(b)#<br>
#b.toString()#<br>
</cfoutput>
java.lang.Boolean
YES
YES
true
coldfusion.runtime.CFBoolean
true
true
true
Why... O why... are you using two different Boolean implementations?
And why has the toString behaviour on the native Java Boolean been monkeyed-with to return "Yes", but the special magic CF-Team-created one behaving as one would expect a sanely-designed language to?Mark Takata (Adobe)
02/16/2022, 4:40 PMMark Takata (Adobe)
02/16/2022, 4:44 PMMark Takata (Adobe)
02/16/2022, 4:54 PMAdam Cameron
coldfusion.runtime.CFBoolean class exists, so I am guessing all booleans in CFML should be those.
(*) not suggesting it was a good reason.Mark Takata (Adobe)
02/17/2022, 3:01 PM