[erlang-questions] Simple multi-case

Christian S <>
Fri Nov 10 13:21:39 CET 2006


> For now that possible only as
>   case getstatus(Id) of
>      S when (S==free) orelse (S==online) -> doX(), doZ(), ok;
>      busy -> doY()
>   end

Do =
case getstatus(Id) of
  free    -> x;
  online -> x;
  busy    -> y
end,

case Do of
  x -> doX();
  y -> doY();
end.

Not less typing, but perhaps a more table-like overview of what to do
and thus more readable code.



More information about the erlang-questions mailing list