<div>My teammate also say I should try to write more function.</div><div>It sounds good!</div><div>And I also hear Erlang don't have any way to return immediately.  </div><div><div>I have some idea to refact it now, thanks!</div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ 原始邮件 ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>发件人:</b> "Bob Ippolito"<bob@redivi.com>;</div><div><b>发送时间:</b> 2013年3月26日(星期二) 上午10:54</div><div><b>收件人:</b> "饕餮"<249505968@qq.com>; <wbr></div><div><b>抄送:</b> "erlang-questions"<erlang-questions@erlang.org>; <wbr></div><div><b>主题:</b> Re: [erlang-questions] How to make a short circuit in erlang ?</div></div><div><br></div>There general strategy is to use more functions or have a flat case on a tuple of comparisons (if that can be done sensibly). You could also use exceptions for flow control, but then you have two problems :)<span></span><div>
<br>On Monday, March 25, 2013, 饕餮 <<a href="mailto:249505968@qq.com">249505968@qq.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>When in other language.We can use like:</div>
<div>example(Something){</div><div>    if( Something == false)</div><div>        return;</div><div>    //do something here;</div><div>}</div><div>But in Erlang.I have to write like:</div><div><div style="line-height:16.799999237060547px">
<div style="line-height:16.799999237060547px">example(Something) -></div><div style="line-height:16.799999237060547px">    if</div><div style="line-height:16.799999237060547px">        Something == false -></div><div style="line-height:16.799999237060547px">
            false;</div><div style="line-height:16.799999237060547px">        true -></div><div style="line-height:16.799999237060547px">            %do something here</div><div style="line-height:16.799999237060547px">
    end.</div></div></div><div style="line-height:16.799999237060547px"><br></div><div style="line-height:16.799999237060547px">That's could make the multiple nested like:</div><div style="line-height:16.799999237060547px">
<div style="line-height:16.799999237060547px">example(Something) -></div><div style="line-height:16.799999237060547px">    if</div><div style="line-height:16.799999237060547px">        Something == false -></div><div style="line-height:16.799999237060547px">
            false;</div><div style="line-height:16.799999237060547px">        true -></div><div style="line-height:16.799999237060547px">            if</div><div style="line-height:16.799999237060547px">                Otherthing == false -></div>
<div style="line-height:16.799999237060547px">                    false</div><div style="line-height:16.799999237060547px">                true -></div><div style="line-height:16.799999237060547px">                    %do something here</div>
<div style="line-height:16.799999237060547px">    end.</div><div style="line-height:16.799999237060547px"><br></div><div style="line-height:16.799999237060547px">Some code could make 5 or more nested in it.</div><div style="line-height:16.799999237060547px">
Is there any idea to make short circuit to reduce of the nested?</div></div></blockquote></div></div>