N
nrk
Vijay said:Did you know that the following if statement is semantically
right, but could logically be wrong?
if ( i = 2 )
{
/* do something */
}
Tip:
The compiler may only produce a waring: "Possibly incorrect
assignment", but we may ignore it. To avoid such a mistake,
just reverse the two identifiers.
Did you know that only a moron (talk about fools rushing in...) would
ignore a compiler diagnostic without giving it considerable attention
and thought? Did you also know that such morons richly deserve the
demons that fly out of their nasal cavities?
if ( 2 == i )
{
/* do something */
}
If '==' is replaced by an '=', the compiler will give an error
saying "Lvalue required".
Looks cute, but is highly counter-intuitive to me. The cognitive
dissonance it induces in me is sufficient to prevent me from using it ever.
-nrk.