Correct syntax of a case clause

mats cronqvist <>
Mon Jun 15 15:49:16 CEST 2009


Sean Cribbs <> writes:

> If you have only a,b,c as possible matches, I'd do it like this:
>
> case Expr of
>  c -> block2;
>  _ -> block1
> end

  this has the huge disadvantage of breaking when you add 'd' to the
  possible values of Expr.

  mats

> info wrote:
>> Hi All,
>>
>> How to formulate a "complex pattern" in a case clause ?
>>
>> case Expr of
>> a,b -> block1;        % if Expr = a or b then block1
>>    c -> block2         % if Expr = c then block2
>> end
>>
>> (a,b) gives an error
>> What is the correct syntax ?
>>
>> John
>>
>>   
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org


More information about the erlang-questions mailing list