Frage

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...

War es hilfreich?

Lösung

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.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top