[erlang-questions] if and fun with erl

Fernando Benavides fernando.benavides@REDACTED
Tue Feb 1 15:02:01 CET 2011


You're right.  Sorry for the confusion.

On Tue, 2011-02-01 at 08:43 -0500, Taylor Venable wrote:

> On Tue, Feb 1, 2011 at 08:28, Fernando Benavides
> <fernando.benavides@REDACTED> wrote:
> > If statements require a true clause. On your module you have one, on the
> > console you don't.
> 
> A true clause is not strictly required; when evaluated, if no matching
> branch of an "if" expression is found, an error occurs just like with
> case:
> 
> 2> X = 3.
> 3
> 3> if X =:= 2 -> ok end.
> ** exception error: no true branch found when evaluating an if expression
> 
> In some (perhaps many) cases you may not even want a true branch, so
> that invalid uses of the if expression cause an error, rather than
> proceeding (for which you must then code defensively). That's part of
> the "let it crash" philosophy.
> 




More information about the erlang-questions mailing list