【发布时间】:2014-06-27 20:38:23
【问题描述】:
我有这个带有 if 语句的代码,它试图让用户输入 yes 或 no,如果用户输入的不是 yes 请求被拒绝。这是我得到的错误:
** exception error: no match of right hand side value "yes\n"
in function messenger:requestChat/1 (messenger.erl, line 80)
代码在这里:
requestChat(ToName) ->
case whereis(mess_client) of
undefined ->
not_logged_on;
_ -> mess_client ! {request_to, ToName},
request_to = io:get_line("Do you want to chat?"),
{_, Input} = request_to,
if(Input == yes) ->
ok;
true -> {error, does_not_want_to_chat}
end
end.
【问题讨论】:
-
我针对此类错误发布了一个规范问题:stackoverflow.com/questions/23577935/…