[erlang-questions] is there "return" in Erlang.

Edmond Begumisa <>
Mon Feb 28 16:51:43 CET 2011


How about...

-define(CONF1, ..).
-define(CONF2, ..).

judge() ->
    judge({a, get_a()}).

judge({a, ?CONF1}) ->
    do_something(?CONF1);
judge({a, _}) ->
    judge({b, get_b()});
judge({b, ?CONF2}) ->
    do_other_thing(?CONF2);
judge({b, _}) ->
    do_things().


- Edmond -

On Mon, 28 Feb 2011 14:14:31 +1100, Wang Wei <> wrote:

> Hello, I has a question about how to convert the bellow C program into  
> Erlang.
>
> void judge()
> {
>     int a;
>     int b;
>
>     a = getA();
>     if (a == CONF1)
>    {
>        doSomeThing(a);
>        return;
>    }
>
>    b = getB();
>    if (b == CONF2)
>    {
>        doOtherThing(b);
>         return;
>    }
>
>    doThings();
>    return;
> }
>
> I think about "case" and "if" construct, but none of it seems work fine,  
> thanks for help.


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the erlang-questions mailing list