[erlang-questions] Correct syntax of a case clause

Martin Engström whongo@REDACTED
Sun Jun 14 21:38:38 CEST 2009


On Sun, Jun 14, 2009 at 7:58 PM, info <info@REDACTED> 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
>

case Expr of
  AB when AB =:= a; AB =:= b -> block1();
  c -> block2()
end
In this case, of course this might be clearer:
case Expr of
  a -> block1();
  b -> block1();
  c -> block2()
end


More information about the erlang-questions mailing list