Possible Duplicate:
How to check for equals? (0 == i) or (i == 0)
Is there a difference between i==0 and 0==i?
I have seen many a times that people use the if(condition) as if(0==x) instead of if(x==0). It is said to be a good practice but can someone explain why so? What difference does it make ? Rather it decreases the readability in my opinion.
The fact that it decreases readability is purely subjective. (I feel the same way though, but that’s because I’ve been dealing with
x==0more than the other way around, so I got used to it).It’s done to prevent accidental assignment:
will yield a compiler error,
won’t.