Hi.
I do have a simple question.
"" == Nullvalue() ? "True" : "false";
I understand that in full null it should be different, but don’t look like that at least in lasted 7.0 version
Thanks
Hi.
I do have a simple question.
"" == Nullvalue() ? "True" : "false";
I understand that in full null it should be different, but don’t look like that at least in lasted 7.0 version
Thanks
This behavior is expected in Lucee because == is a loose comparison operator and applies type coercion.
So:
"" == NullValue() // true
does not mean empty string and null are the same value. It means the comparison was coerced.
If you need reliable null handling, do not use == for null checks. Use isNull(value) for null, and separate empty-string checks.
Thanks!
Also === should work no?
Yes, === should be false here, because it is a strict comparison and does not coerce null and "" into the same thing.
So the correct distinction is:
== can coerce, === does not.
For actual null handling, though, isNull(x) is still the better and clearer check.