[erlang-questions] How to make a short circuit in erlang ?

Bob Ippolito bob@REDACTED
Tue Mar 26 03:54:29 CET 2013


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 :)

On Monday, March 25, 2013, 饕餮 <249505968@REDACTED> wrote:

> When in other language.We can use like:
> example(Something){
>     if( Something == false)
>         return;
>     //do something here;
> }
> But in Erlang.I have to write like:
> example(Something) ->
>     if
>         Something == false ->
>             false;
>         true ->
>             %do something here
>     end.
>
> That's could make the multiple nested like:
> example(Something) ->
>     if
>         Something == false ->
>             false;
>         true ->
>             if
>                 Otherthing == false ->
>                     false
>                 true ->
>                     %do something here
>     end.
>
> Some code could make 5 or more nested in it.
> Is there any idea to make short circuit to reduce of the nested?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130325/4cae6748/attachment.htm>


More information about the erlang-questions mailing list