【发布时间】:2014-03-19 23:20:52
【问题描述】:
我最近开始学习erlang,但是遇到了一个让我很困惑的错误。
最后一行的错误是syntax error before: 'end'。我查看了示例并试图找到错误,但此刻我完全迷失了。有什么想法吗?
ChannelToJoin = list:keysearch(ChannelName,1,State#server_st.channels),
case ChannelToJoin of
% Channel exists.
{value, Tuple} ->
if
%User is not a member of the channel
not list:member(UserID, Tuple) ->
%Add the user to the channel
Tuple#channel.users = list:append(Tuple#channel.users, [UserID]);
% If the user is already a member of the channel.
true -> true
end;
%Channel doesn't exist
false ->
%Create new channel and add the user to it.
NewState = State#server_st{channels = list:append(State#server_st.channels, NewChannel = #channel{name = ChannelName, users = [UserID]}
end
【问题讨论】:
-
你能发布更多代码吗?这对我来说看起来不错,除了您尝试更新
if中的Tuple记录。记住:erlang 中的变量是只读的
标签: erlang