#1480 Map#map doesn't preserve ordered/caseInsensitive

tonsky Wed 6 Apr 2011

If would be nice to keep order of elements in Map#map, if it is possible:

>>> z := [:]
>>> z.ordered = true
>>> z["a"] = 1
>>> z["b"] = 2
>>> z["c"] = 3
>>> z
[a:1, b:2, c:3]

>>> z.map { it }
[b:2, c:3, a:1]

brian Wed 6 Apr 2011

Promoted to ticket #1480 and assigned to brian

That seems like a pretty good idea to me - maintain order (but probably not caseInsensitive)

tonsky Thu 7 Apr 2011

Why not maintain Map#caseInsensitive too? Mapped map will have the same keys, it would be strange if default ["key":obj] has kEy key, but when mapped it will not.

brian Thu 7 Apr 2011

Why not maintain Map#caseInsensitive too?

Yeah I think you are right since Map.map doesn't let you change keys (only values)

brian Tue 31 May 2011

Ticket resolved in 1.0.59

Map.map will now preserve both ordered and caseInsensitive state

brian Tue 31 May 2011

Renamed from Map#map doesn’t preserve elements order for ordered maps to Map#map doesn't preserve ordered/caseInsensitive

Login or Signup to reply.