[erlang-questions] if vs. case (long)

Ulf Wiger ulf@REDACTED
Thu Mar 13 08:38:19 CET 2008


2008/3/13, Jay Nelson <jay@REDACTED>:

>  My default instinct in erlang is to use case because I know it can
>  always be easily expanded to include more branches, and it guarantees
>  that all legal cases are enumerated so nothing is hidden in the order
>  of branches:
>
>  Var = computeStuff(),
>  case DebugOn of
>     true -> log(Var);
>     false -> ok
>  end,


A colleague of mine would most definitely write this as

  DebugOn andalso log(Var).

I'll save him the trouble of pointing that out. (:

We've had some discussions about whether this is good style.

BR,
Ulf W



More information about the erlang-questions mailing list