Effective use of ==

This tip submitted by Er.Nathan on 2006-11-30 23:47:28. It has been viewed 8576 times.
Rating of 4.4 with 79 votes



Use if statements like this if( 1 == count ) insteed of like this if ( count == 1).

In case if you mistakenly put in just a single = signin the second case, like this:

if( count = 1) //count will be assigned with 1

whereas if you made the same mistake with the constant value first:

if( 1 = count ) //Will give Error



More tips

Help your fellow programmers! Add a tip!