[erlang-questions] if vs. case (long)
Thu Mar 13 09:12:20 CET 2008
Ulf Wiger wrote:
> 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
> 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.
> Ulf W
> erlang-questions mailing list
that's too verbose, and log/1 has to return a boolean. here's the
[log(Var) || DebugOn].
p.s. sarcasm! this construct is only to be used in obfuscated erlang
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 179 bytes
Desc: not available
More information about the erlang-questions