【发布时间】:2011-03-04 05:53:41
【问题描述】:
我这辈子都无法让 list:keyfind 在 Erlang 中像我期望的那样工作。
我有以下 eunit 测试:
should_find_key_test() ->
NewList = lists:keystore("key", 1, [], {"key", "value"}),
Value = case lists:keyfind("key", 1, NewList) of
false ->
notfound;
{_key, _value} ->
_value
end,
?debugVal(Value).
每当我运行此测试时,我都会收到以下错误消息:
indextests:should_find_key_test (module 'indextests')...失败 ::错误:undef 在函数列表中:keyfind/3 称为 keyfind("key",1,[{"key","value"}]) 从 indextests 调用:should_find_key_test/0
谁能看出我做错了什么?
是不是说lists:keyfind 已经不存在了?
【问题讨论】:
-
你运行的是哪个版本的 Erlang?
lists:keyfind/3是最新的,但我不记得它是在哪个版本中添加的。
标签: erlang