[erlang-questions] conditional expressions

Hynek Vychodil vychodil.hynek@REDACTED
Sat Nov 15 19:37:39 CET 2008


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?
>

Yes, you missed that shell binds X to aaa in previous expression ;-)

But I think, less magic will be

X = case foo() of
      [] -> bar();
      Y -> Y
  end


> 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
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081115/e53cfe6e/attachment.htm>


More information about the erlang-questions mailing list