Better coding style for comparison

This tip submitted by nids on 2006-01-31 07:57:07. It has been viewed 38464 times.
Rating of 5.6 with 534 votes



Always try to compare like

if ( 0 == i )

rather than

if ( i == 0)

In this way you can catch error for unintended assignments like

if ( 0 = i)



More tips

Help your fellow programmers! Add a tip!