我有一些Erlang代码,Emacs告诉我,我有"不平衡的括号",但我无法弄清楚是什么问题......以下是代码:
receive
{connect, Client} ->
NewPid = spawn_link(fun() -> game_loop(0,0)),
Client ! NewPid,
handle_connect()
end.
错误发生在以NewPid开始的行......
答案 0 :(得分:2)
为了正确完全定义匿名函数,您忘记了end
之后的game_loop(0,0)
。因此,该片段应如下所示:
receive
{connect, Client} ->
NewPid = spawn_link(fun() -> game_loop(0,0) end),
Client ! NewPid,
handle_connect()
end.