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

Robert Virding rvirding@REDACTED
Thu Nov 28 11:06:29 CET 2013


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131128/187cbddb/attachment.htm>


More information about the erlang-questions mailing list