lists:keyfind problems

Posted by dagda1 on Stack Overflow See other posts from Stack Overflow or by dagda1
Published on 2010-06-15T23:09:17Z Indexed on 2010/06/15 23:12 UTC
Read the original article Hit count: 245

Filed under:

Hi,

I cannot for the life of me get lists:keyfind to work as I expect in Erlang.

I have the following eunit test:

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).

Whenever I run this test I get the following error message:

indextests:should_find_key_test (module 'indextests')...failed ::error:undef in function lists:keyfind/3 called as keyfind("key",1,[{"key","value"}]) in call from indextests:should_find_key_test/0

Can anyone see what I am doing wrong?

Is it saying that lists:keyfind no longer exists?

Cheers

Paul

© Stack Overflow or respective owner

Related posts about erlang