Erlang编译错误 [英] Erlang compiler error
问题描述
我有以下代码
loop(Data) ->
receive
{Key, Value} ->
[{Key, Value}|Data];
{Key} ->
member(Key, Data);
14 loop(Data);
stop ->
io:format("server_stopped"),
ok
end .
我收到以下错误(我在代码中放了第14行)
and I get the following error (I put the line number 14 in the code)
./ dist_erlang.erl:14:语法错误之前:';'
./dist_erlang.erl:2:function loop / 1 undefined
./dist_erlang.erl:28:警告:功能成员/ 2未使用
./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
我不知道什么语法问题是用上面的代码。我有一个方法称为成员,由于第14行的语法错误导致错误。我确定。
I am not sure what the syntax problem is with the above code. I have a method called member which is giving the error because of a different syntax error on line 14 I am sure.
任何帮助,谢谢。
推荐答案
在Erlang中,表达式由逗号分隔(并且子句以分号分隔)。尝试:
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.
这篇关于Erlang编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!