Code Style: Difference between revisions
Content deleted Content added
m WIP |
m WIP |
||
Line 380:
=== if, if-else, if else-if else Statements ===
The <code>if
<pre>
Line 431:
if (shortCondition)
oneLineStatement;
</pre>
=== for Statements ===
The <code>for</code> code block should always be enclosed by curly braces. For simple single-line loops, the curly braces may be omitted.
<pre>
for (initialization; condition; update) {
statementOne;
statementN;
}
for (initialization; aReallyLongCondition;
updateStatement)
{
statement;
}
</pre>
Simple, single line body may omit curly braces:
<pre>
for (initialization; condition; update)
aSimpleStatement;
</pre>
An empty for statement -- one in which all the work is done in the initialization, condition, and update clauses -- should have the following form:
<pre>
for (initialization; condition; update);
</pre>
|