[erlang-questions] illegal guard expression for IF illegal guard expression for "if"

Barco You barcojie@REDACTED
Fri Dec 2 10:30:54 CET 2011


Why does the following expression got "illegal guard expression" when
compiling:
X = 0.5,
if
    random:uniform() < X ->      %error reported for this line
           good;
    true ->
           bad
end.

But if I change it to following expression, it's ok:
X = 0.5,
Ran = random:uniform(),
if
    Ran < X ->
           good;
    true ->
           bad
end.

BRs,
Barco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111202/00628b0d/attachment.htm>


More information about the erlang-questions mailing list