[erlang-questions] maps:keys/1, values/1 stability?
Nathaniel Waisbrot
nathaniel@REDACTED
Sat Dec 12 13:16:12 CET 2015
The implementation in 18.1 (
https://github.com/erlang/otp/blob/1523be48ab4071b158412f4b06fe9c8d6ba3e73c/erts/emulator/beam/erl_map.c#L2299-L2331)
certainly looks like they use the same ordering.
However, it would _never_ be a good idea to depend on that behavior. If you
need to loop over key/value pairs, use maps:map/2 or maps:fold/3 or
maps:to_list/1.
On Fri, Dec 11, 2015 at 1:35 PM, Kevin Montuori <montuori@REDACTED> wrote:
>
> Hi All --
>
> The maps documenation indicates that keys/1 and values/1 will return
> results in arbitrary order, which makes sense. I'm wondering if they'll
> return in the *same* arbitrary order. In other words, is this assertion
> always correct?
>
> M = maps:from_list(lists:zip(maps:keys(M), maps:values(M))).
>
> Thanks for any insight.
>
> k.
>
> --
> Kevin Montuori
> montuori@REDACTED
> _______________________________________________
> 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/20151212/2de2eca7/attachment.htm>
More information about the erlang-questions
mailing list