|
|
|
|
|
by tracker1
3995 days ago
|
|
Personally, I say if a statement continues on a different line, then you should use braces //okay
if (condition) return foo;
//not okay
if (condition)
return foo;
//not okay
if (condition) do_foo();
else do_bar();
In the second case, the else can be considered a continuation. In the first example, there's little chance of confusion or the introduction of an error, in the second and third, that is not necessarily the case.If it doesn't look/fit well on one line, break it up with braces. |
|
if((somevar != checkvar((byte)othervar)) & (i != 3)) somefunc();
someotherfunc();
A bit exaggerating, I agree, but not far off from some real-world examples and quite confusing.