Changeset 30737

Show
Ignore:
Timestamp:
03/04/08 00:25:26 (2 years ago)
Author:
mrowe@apple.com
Message:

2008-03-04 Mark Rowe < mrowe@apple.com>

Reviewed by Sam Weinig.

Add a note about preferring if over else if when the previous if is terminated by a return statement.

  • coding/coding-style.html:
Location:
trunk/WebKitSite
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebKitSite/ChangeLog

    r30094 r30737  
     12008-03-04  Mark Rowe  <mrowe@apple.com> 
     2 
     3        Reviewed by Sam Weinig. 
     4 
     5        Add a note about preferring if over else if when the previous if is terminated by a return statement. 
     6 
     7        * coding/coding-style.html: 
     8 
    192008-02-08  Adam Roben  <aroben@apple.com> 
    210 
  • trunk/WebKitSite/coding/coding-style.html

    r29874 r30737  
    202202</li> 
    203203 
    204 <li>An else statement should go on the same line as a preceding close brace. 
     204<li>An <code>else</code> statement should go on the same line as a preceding close brace. 
    205205<h4 class="right">Right:</h4> 
    206206<pre class="code"> 
     
    218218} 
    219219else { 
     220    ... 
     221} 
     222</pre> 
     223</li> 
     224 
     225<li>An <code>else if</code> statement should be written as an <code>if</code> statement when the prior <code>if</code> concludes with a <code>return</code> statement. 
     226<h4 class="right">Right:</h4> 
     227<pre class="code"> 
     228if (condition) { 
     229    ... 
     230    return someValue; 
     231} 
     232if (condition) { 
     233    ... 
     234} 
     235</pre> 
     236 
     237<h4 class="wrong">Wrong:</h4> 
     238<pre class="code"> 
     239if (condition) { 
     240    ... 
     241    return someValue; 
     242} else if (condition) { 
    220243    ... 
    221244}