Question

I have some Erlang code and Emacs is telling me that I have "Unbalanced parenthesis", but I can't figure what is wrong... Here is the code:

    receive
    {connect, Client} ->
        NewPid = spawn_link(fun() -> game_loop(0,0)),
        Client ! NewPid,
        handle_connect()
    end.

The error is at the row starting with NewPid...

Was it helpful?

Solution

You forgot the end after game_loop(0,0) in order to correctly completely define an anonymous function. The snippet should therefore look as follows:

receive
{connect, Client} ->
    NewPid = spawn_link(fun() -> game_loop(0,0) end),
    Client ! NewPid,
    handle_connect()
end.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top