On Thu, Aug 27, 2009 at 3:35 PM, Howard Lewis Ship <hls...@gmail.com> wrote:

>
> Is the order of keys in a map predictable?  I have some tests I'm
> concerned about, where the keys and values in a map are converted to a
> string (ultimately, a URL, as query parameters) and the order will
> affect the output string.
>
> I could sort the keys, but then I'm changing my code to support the
> test in a somewhat non-trivial way.
>
> Literally: when iterating over the key/value pairs, the order seems to
> be the order in which the key/values are defined in the map. Is this
> true?


The order of keys in a map is basically undefined. In practice, for small
maps it tends to be insertion order and for maps with more than eight keys,
in order of the keys' hashCode() values (as Java objects). But this behavior
should probably not be relied on.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to