[erlang-questions] Return [Value] of erlang dict:find fetch

Bengt Kleberg bengt.kleberg@REDACTED
Thu Nov 28 11:15:37 CET 2013


These are opinions, not facts.

It is better to err on the side of caution. Some readers of
Erlang-questions are _very_ sensitive to not separating facts from
opinions.

Presumably they have only ever seen a part of the Internet where this
http://xkcd.com/386/ makes no sense.


bengt

On Thu, 2013-11-28 at 11:06 +0100, Robert Virding wrote:
> No, they are facts. :-) The documentation of dict:append says:
> 
> "This function appends a new Value to the current list of values
> associated with Key."
> 
> 
> So it manages a list of values.
> 
> 
> Robert
> 
> 
> 
> On 25 November 2013 09:02, Bengt Kleberg <bengt.kleberg@REDACTED>
> wrote:
>         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
>         
>         _______________________________________________
>         erlang-questions mailing list
>         erlang-questions@REDACTED
>         http://erlang.org/mailman/listinfo/erlang-questions
> 
> 




More information about the erlang-questions mailing list