[erlang-questions] guard subexpressions resulting in a runtime error
José Valim
jose.valim@REDACTED
Sun Jul 22 11:03:06 CEST 2012
>
> "Guard subexpressions resulting in a runtime error are treated as
> returning false"
>
> But with this function definition:
>
> -module(t1).
> -export([guard1/1]).
>
> guard1(N) when ((N/0 == 0) or N==1) ->
> hello.
>
>
In this example, the guard subexpression is the whole ((N/0 == 0) or N==1).
You can use , (meaning and) or ; (meaning or) to provide subexpressions:
guard1(N) when N/0 == 0; N==1 ->
hello.
The example above should give you the expected result.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120722/4ff7492a/attachment.htm>
More information about the erlang-questions
mailing list