[erlang-questions] [clarify] Disjoint when clause

Andreas Hillqvist <>
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 <>:
> 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
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list