Incautious use of semicolons
suggest changeBe careful with semicolons. Following example
if (x > a); a = x;
actually means:
if (x > a) {} a = x;
which means x
will be assigned to a
in any case, which might not be what you wanted originally.
Sometimes, missing a semicolon will also cause an unnoticeable problem:
if (i < 0) return day = date[0]; hour = date[1]; minute = date[2];
The semicolon behind return is missed, so day=date[0] will be returned.
One technique to avoid this and similar problems is to always use braces on multi-line conditionals and loops. For example:
if (x > a) { a = x; }
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents