[erlang-questions] an erlang "gotcha"
Thu Apr 5 13:11:27 CEST 2007
> Is there a place where difficulties with erlang and their solutions are
> described? Perhaps another page at Trapexit.
> Here's one that got me.
> run() ->
> Pid = spawn(fun() -> io:fwrite("spawned~n") end),
> L = [1, 2, 3],
> io:fwrite("Pid=~p L=~p~n", [Pid, L]),
> is_pid(Pid) and L /=  ->
For what you want, it should be :
is_pid(Pid) and (L /= ) ->
See operator precedence in the reference manual.
> io:fwrite("it worked~n");
> true ->
> io:fwrite("it failed~n")
> It prints out "it failed". If you change the 'and' to 'andalso' it works.
More information about the erlang-questions