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.".<br><br>You can unbind/forget X in the shell with f() or f(X), see help().<br>
<br><span style="font-family: courier new,monospace;">1> case [] of [] -> X = aaa; X -> ok end.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">aaa</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">2> X.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">aaa</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">3> case bbb of [] -> X = aaa; X -> ok end.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">** exception error: no case clause matching bbb</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">4> X.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">aaa</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">5> f(X).</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ok</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">6> X. </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">* 1: variable 'X' is unbound</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">7> case bbb of [] -> X = aaa; X -> ok end.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ok</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">8> X.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">bbb</span><br style="font-family: courier new,monospace;">
<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>