让人抓狂的代码
jopen 12年前
<p> <strong>1. 确保这个值等于 ture</strong></p> <div class="cnblogs_code"> <pre><span style="color:#0000ff;">if</span> (someBoolean == <span style="color:#0000ff;">true</span>) { doSomething (); }</pre> </div> <p> <strong>2. 只有等于 ture 时我才 return ture</strong></p> <div class="cnblogs_code"> <pre><span style="color:#0000ff;">if</span> (result == <span style="color:#0000ff;">true</span>) <span style="color:#0000ff;">return</span> <span style="color:#0000ff;">true</span>;<span style="color:#0000ff;">else</span> <span style="color:#0000ff;">return</span> result;</pre> </div> <p> <strong>3. 我就是不信任 if</strong></p> <div class="cnblogs_code"> <pre><span style="color:#0000ff;">if</span> (result <= <span style="color:#800080;">10</span>) { handling (); }<span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span> (result > <span style="color:#800080;">10</span>) { otherHandling (); }<span style="color:#0000ff;">else</span> { handling (); <span style="color:#008000;">//</span><span style="color:#008000;"> to be sure</span><span style="color:#008000;"> </span>}</pre> </div> <p><strong> 4. 要写出一看就懂的代码</strong></p> <div class="cnblogs_code"> <pre><span style="color:#0000ff;">function</span> DocumentDotWrite (s){ document.write (s); }</pre> </div> <div id="come_from"> 来自: <a id="link_source2" href="/misc/goto?guid=4958523475987551297" target="_blank">外刊IT评论</a> </div>