[erlang-questions] [clarify] Disjoint when clause

Jay Nelson <>
Fri May 16 14:54:49 CEST 2008


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




More information about the erlang-questions mailing list