Not null check
-
How about this piece of code:
if (a == null == false) { }
Spent some time before figuring out it is a version ofif (а != null) {}
when in doubt, you can look it up and then clarify by adding parentheses, like so:
if ( ( (a==null) == false ) == true ) {...}
:)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
-
How about this piece of code:
if (a == null == false) { }
Spent some time before figuring out it is a version ofif (а != null) {}
A a clear and sustainable piece of code, this is truly a horror and definitely deserves its place in the Hall of Shame.
I wasn't, now I am, then I won't be anymore.
-
when in doubt, you can look it up and then clarify by adding parentheses, like so:
if ( ( (a==null) == false ) == true ) {...}
:)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
Luc Pattyn wrote:
if ( ( (a==null) == false ) == true ) {...}
can you extend this recursively? only to be very very sure:
if ( ( ( ( ( (a==null) == false) == true) == true) == true) == true)
to shock afterworkers and make compiler happy, one could sometimes say
== true
and== false
:laugh: -
How about this piece of code:
if (a == null == false) { }
Spent some time before figuring out it is a version ofif (а != null) {}
Related to the above:
flag = bool(int(flag) - 1);
-
Related to the above:
flag = bool(int(flag) - 1);
-
when in doubt, you can look it up and then clarify by adding parentheses, like so:
if ( ( (a==null) == false ) == true ) {...}
:)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
Just to make it more subtle add a little "!" at the beginning
if ( !( ( ( (a==null) == false ) == true ) == false)) {...}
:suss:
-
Just to make it more subtle add a little "!" at the beginning
if ( !( ( ( (a==null) == false ) == true ) == false)) {...}
:suss:
This one would be even more subtle :cool:
if ( !( !( !( !(a==null) == true ) == false ) == true)) {...}
-
This one would be even more subtle :cool:
if ( !( !( !( !(a==null) == true ) == false ) == true)) {...}
How about this one? :-D
if ( true == (!((!(((a ?? true) is bool) ? true : false) == false) == true) == false)) {...}
-
when in doubt, you can look it up and then clarify by adding parentheses, like so:
if ( ( (a==null) == false ) == true ) {...}
:)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
I used to work at Accenture, they used to make us bracket like that to "Disambiguate" the otherwise very clear logic X|
Sort of a cross between Lawrence of Arabia and Dilbert.[^]
-Or-
A Dead ringer for Kate Winslett[^] -
How about this one? :-D
if ( true == (!((!(((a ?? true) is bool) ? true : false) == false) == true) == false)) {...}