Lately, I've been reading some code that has
if (! (a == b) )
instead of
if ( a != b )
in some places.
Obviously these are logically equivalent, but I'm wondering if there is any particular reason to use one over the other.
Are there certain circumstances where one is preferable, or is it all just a matter of personal style?
I really prefer
if ( a != b )
simply because you are supposed to read less and you understand more quickly the message the programmer wanted to transmit.
Remember programmers spend more time reading code than writing it, so the more you can do to make code more understandable, the better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With