Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982)
by naitgacem on Saturday January 06, 2024 @07:36AM
(#38890933)
just a fun little anecdote.
I wrote a piece of code that said ` if ( boolean_variable == true)`
this was meant to be "if neither false nor null", since the variable was nullable (kotlin), until someone else tried to "fix the beginner mistake" :P
luckily kotlin requires you handle the nullability and the other person immediately figured out what was going on.
The other person was me, a couple of months down the line.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982)
by MaxBarraclough on Saturday January 13, 2024 @07:48AM
(#38979490)
If the purpose of quirky code isn't immediately clear from the context (and if the code can't easily be reworked to make it cleaner), it's a good candidate for commenting.
I otherwise agree with your comment: in most cases, unnecessary parentheses make the code slower to read, just like unnecessary "==true".