[erlang-questions] conditional expressions

Fredrik Svahn fredrik.svahn@REDACTED
Sat Nov 15 22:22:04 CET 2008


X is bound to aaa in the first line you enter in the shell, so your second
line is really "case bbb of [] -> aaa = aaa; aaa -> ok end.".

You can unbind/forget X in the shell with f() or f(X), see help().

1> case [] of [] -> X = aaa; X -> ok end.
aaa
2> X.
aaa
3> case bbb of [] -> X = aaa; X -> ok end.
** exception error: no case clause matching bbb
4> X.
aaa
5> f(X).
ok
6> X.
* 1: variable 'X' is unbound
7> case bbb of [] -> X = aaa; X -> ok end.
ok
8> X.
bbb

2008/11/15 damien morton <dmorton@REDACTED>

> 1> case [] of [] -> X = aaa; X -> ok end.
> aaa
> 2> case bbb of [] -> X = aaa; X -> ok end.
> ** exception error: no case clause matching bbb
>
> am I missing something?
>
> On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist <masse@REDACTED> wrote:
>
>>
>>   strangely, this also works;
>>
>> case foo() of
>>  [] -> X = bar();
>>  X -> ok
>> end
>>
>>  as long as X is bound in each clause, you're golden.
>>
>>  this might qualify as a gotcha.
>>
>>  mats
>>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081115/4e04fec9/attachment.htm>


More information about the erlang-questions mailing list