[erlang-questions] Return [Value] of erlang dict:find fetch
Bengt Kleberg
bengt.kleberg@REDACTED
Mon Nov 25 09:02:38 CET 2013
These are opinions, not facts.
dict:append/3 creates a list of values. Try calling it several times and
you will see.
If you only want one value use dict:store/3.
bengt
On Mon, 2013-11-25 at 15:38 +0800, 王靖易 wrote:
> Hi,
> I'm a beginner of erlang and have found some problems in my project.
> After doing some google I found here and wish someone could help me.
> I'm using the erlang structure 'dict' for a key-value table in my
> program, but I found that the return value of dict:fetch and dict:find
> is actually [Value] or {ok, [Value]} (means I get a list containing
> the value instead of the original one). However, this is not the
> problem, the real problem is, this happens only in some situations
> which I can't find what it is.
> An example:
> Eshell V5.8.5 (abort with ^G)
> 1> A = dict:new().
> {dict,0,16,16,8,80,48,
> {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
> {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
> 2> A2 = dict:append(key, value, A).
> {dict,1,16,16,8,80,48,
> {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
> {{[],[],[],[],[],[],[],[],[],
> [[key,value]],
> [],[],[],[],[],[]}}}
> 3> dict:find(key, A2).
> {ok,[value]}
>
>
> My erlang environment is R14B04 on ubuntu 12.04. Could any one tell
> me why the return value of dict:find is not the same as the doc?
>
>
> Best regards,
> Jingyi Wang
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list