[erlang-questions] an erlang "gotcha"

Anthony Shipman als@REDACTED
Thu Apr 5 12:38:26 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 /= [] ->
	    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.

Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.

More information about the erlang-questions mailing list