- = and == confusions
The '=' operator is for assignment, while '==' is for comparison. Mix these up and you will have a major headache as the variable has been changed (or not)
- The 'if' block
if (x == 3)
y = 43;
z = 0;
{do something more}
Guess what? if x is equal to 3, only the statement 'y = 43;' will be executed, while 'z = 0' will be executed no matter what, which isn't the initial intention.
There are a list of programming pitfalls here
No comments:
Post a Comment