Always do equality check with rvalue on the left

A common error in many languages is accidentally omitting an equals sign where a comparison was intended. Example;

void somefunc(int i) {
   if (i = 2) {     // was supposed to be "(i == 2)"
      // ...
   } else {
      // ...
   }
}

What makes it easily missed is that it compiles and executes just fine in many cases, albeit erroneously. Bugs like this can live in the code for long periods of time before being caught.

An easy habit to get into is to always put the rvalue on the left side when doing == comparisons. E.g.

void somefunc(int i) {
   if (2 == i) {
      // ...
   }
}

this way if (when!) you do accidentally omit an = then the compiler catches it for you.