[erlang-questions] [clarify] Disjoint when clause

Andreas Hillqvist andreas.hillqvist@REDACTED
Fri May 16 15:04:30 CEST 2008


I have not tested. But shouldent it work to write it like:
    f(A,B,C) when is_integer(A), is_integer(B), (C =:= foo orelse C =:= bar) ->
        do_stuff(A,B,C).


Kind regards
Andreas Hillqvist

2008/5/16, Jay Nelson <jay@REDACTED>:
> I would like to do the following:
>
> f(A,B,C) when is_integer(A), is_integer(B), (C =:= foo; C =:= bar) ->
>  do_stuff(A,B,C).
>
> Of course, the parens aren't allowed.  Are there any better choices
> than:
>
> f(A,B,C) when is_integer(A), is_integer(B), C =:= foo;
>         is_integer(A), is_integer(B), C =:= bar ->
>   do_stuff(A,B,C).
>
> -or-
>
> f(A,B,C) when is_integer(A), is_integer(B), C =:= foo ->
>   do_stuff(A,B,C);
> f(A,B,C) when is_integer(A), is_integer(B), C =:= bar ->
>   do_stuff(A,B,C).
>
>
> Or (what I am currently using):
>
> f(A,B,C) when is_integer(A), is_integer(B) ->
>   f_auth(A,B,C).
>
> f_auth(A,B,C) when C =:= foo; C =:= bar ->
>   do_stuff(A,B,C).
>
>
> jay
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list