Friday, November 7, 2008

Building Tolerance For Allergies



Commonly, we have to compare constants with variables. Traditionally, it is achieved like that:
 if (variable == CONSTANT) 
{
...
}
But this is a common source of errors. If we write '=' instead '==', compilation will be achieved correctly, but execution maybe crash.

In order to avoid this problem, the first member of the comparison must be the constant:
 if (CONSTANT == variable) 
{
...
}
This way, if we forget one 'equal' a compilation error will arise.

0 comments:

Post a Comment