[erlang-questions] conditional expressions
Sat Nov 15 19:40:53 CET 2008
On Sun, Nov 16, 2008 at 05:17:52AM +1100, damien morton wrote:
> 1> case  of  -> X = aaa; X -> ok end.
> 2> case bbb of  -> X = aaa; X -> ok end.
> ** exception error: no case clause matching bbb
> am I missing something?
From section '6.8 Case' of the Erlang Reference Manual (Version 5.6.5)
"If there is no matching pattern with a true guard sequence, a case_clause run-time error will occur."
bbb does not match anything in the second case above; you could substitute
aaa for X in the second case and it would result the same.
> On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist <masse@REDACTED>
> strangely, this also works;
> case foo() of
>  -> X = bar();
> X -> ok
> as long as X is bound in each clause, you're golden.
> this might qualify as a gotcha.
> 1. mailto:masse@REDACTED
> erlang-questions mailing list
Portland, Oregon, USA
More information about the erlang-questions