Code Style: Difference between revisions

Content deleted Content added
Chill (talk | contribs)
m WIP
Chill (talk | contribs)
m WIP
Line 380:
 
=== if, if-else, if else-if else Statements ===
The <code>if/while/for</code> code block should always be enclosed by curly braces. Except forFor simple <code>if</code> single-line statements without <code>else/else-if</code>, wherethe curly braces can be omitted.
 
<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>