开发者

Erlang compiler error

I have the following code

loop(Data) ->
receive
    {Key, Value} ->
    [{Key, Value}|Data];
    {Key} ->
        member(Key, Data);
14  loop(Data);
    stop ->
        io:format("server_stopped"),
        ok  
end .

and I get the following error (I put the line number 14 in the code)

./dist_erlang.erl:14: syntax error before: ';' ./dist_erlang.erl:2: function loop/1 undefined ./dist_erlang.erl:28: Warning: function member/2 is unused

I am not sure what the syntax problem is with the a开发者_StackOverflow中文版bove code. I have a method called member which is giving the error because of a different syntax error on line 14 I am sure.

Any help is appreciated thanks.


In Erlang, expressions are separated by commas (and clauses are separated by semicolons). Try:

loop(Data) -> 
    receive 
        {Key, Value} -> 
            loop([{Key, Value}|Data]); 
        {Key} -> 
            member(Key, Data),
            loop(Data);
        stop -> 
            io:format("server_stopped"), 
            ok   
    end.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜