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

Ivan Uemlianin ivan@REDACTED
Tue Mar 26 08:10:15 CET 2013


On 26/03/2013 06:36, 饕餮 wrote:
> ...
> Use if could be better I think,like:
> example(Foo,Bar,Ugh) ->
> if
>      Foo =:= false -> ...
>      Bar =:= false -> ...
>      Ugh=:= false -> ...
>      true -> ...
> (change some logic could remove the "=:= false", to make the code more
> clean)

How about

     example(Foo,Bar,false) ->
         do_first_thing();

     example(Foo,false,Ugh) ->
         do_second_thing();

     example(false,Bar,Ugh) ->
         do_third_thing();

     example(Foo,Bar,Ugh) ->
         do_default_thing().

Best wishes

Ivan


-- 
============================================================
Ivan A. Uemlianin PhD
Llaisdy
Speech Technology Research and Development

                     ivan@REDACTED
                      www.llaisdy.com
                          llaisdy.wordpress.com
               github.com/llaisdy
                      www.linkedin.com/in/ivanuemlianin

                         festina lente
============================================================



More information about the erlang-questions mailing list