You are evaluating these in the shell. In the first case X is bound to aaa, which means that when you evaluate the second case X is already bound. Which means that there is no matching clause. If you do:<br><br>1> case [] of [] -> X = aaa; X -> ok end.<br>
aaa<br>2> case bbb of [] -> Y = aaa; Y -> ok end.<br>ok<br>3> {X,Y}.<br>{aaa,bbb}<br><br>it works.<br><br>Robert<br><br><div class="gmail_quote">2008/11/15 damien morton <span dir="ltr"><<a href="mailto:dmorton@bitfurnace.com">dmorton@bitfurnace.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>1> case [] of [] -> X = aaa; X -> ok end.</div><div>aaa</div><div>2> case bbb of [] -> X = aaa; X -> ok end.</div>
<div>** exception error: no case clause matching bbb</div><div><br></div><div>am I missing something?</div>
<br><div class="gmail_quote">On Sun, Nov 16, 2008 at 4:42 AM, mats cronqvist <span dir="ltr"><<a href="mailto:masse@kreditor.se" target="_blank">masse@kreditor.se</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><br>
</div> strangely, this also works;<br>
<br>
case foo() of<br>
[] -> X = bar();<br>
X -> ok<br>
end<br>
<br>
as long as X is bound in each clause, you're golden.<br>
<br>
this might qualify as a gotcha.<br>
<font color="#888888"><br>
mats<br>
</font></blockquote></div><br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>