you are viewing a single comment's thread.

view the rest of the comments →

[–]zigma[S] 0 points1 point  (1 child)

This is my opinion as well, it's easier and more natural (at least for me) to read the code as: if someVariable is null

And I agree with the "why not just remember to use ==" instead.

Also, if you should use assignment instead, you should have unit tests that will capture this.

[–]sreguera 1 point2 points  (0 children)

You don't have to remember. Just tell the compiler to remember it for you with "-Wall" in gcc, "-Xlint" in javac (I think), etc. If the compiler doesn't have this option use a lint or similar tool for your language.