mbonnin
10/30/2020, 1:56 PMmutableMapOf()
to preserve iteration order on key re-insertion like a LinkedHashMap ?Ryan
10/30/2020, 2:04 PMspand
10/30/2020, 2:05 PMmbonnin
10/30/2020, 2:05 PMmbonnin
10/30/2020, 2:05 PMRyan
10/30/2020, 2:06 PMRyan
10/30/2020, 2:06 PMmbonnin
10/30/2020, 2:07 PMmbonnin
10/30/2020, 2:08 PMmutableMapOf()
calls LinkedHashMap()
which is why it's very tempting to assume the same API as LinkedHashMap
mbonnin
10/30/2020, 2:08 PMspand
10/30/2020, 2:09 PMLinkedHashMap
is a kotlin typembonnin
10/30/2020, 2:09 PMmbonnin
10/30/2020, 2:09 PMspand
10/30/2020, 2:10 PMmbonnin
10/30/2020, 2:10 PMspand
10/30/2020, 2:10 PMspand
10/30/2020, 2:11 PMNir
10/30/2020, 2:13 PMNir
10/30/2020, 2:14 PMmbonnin
10/30/2020, 2:15 PMLinkedHashMap
keeps order on re-insertion remainsRyan
10/30/2020, 2:17 PMspand
10/30/2020, 2:17 PMNir
10/30/2020, 2:17 PMNir
10/30/2020, 2:18 PMx["foo"] = 5
Nir
10/30/2020, 2:18 PMmbonnin
10/30/2020, 2:18 PMmbonnin
10/30/2020, 2:19 PMNir
10/30/2020, 2:22 PMNir
10/30/2020, 2:22 PMmbonnin
10/30/2020, 2:23 PMspand
10/30/2020, 2:24 PMmbonnin
10/30/2020, 2:24 PMNir
10/30/2020, 2:28 PMNir
10/30/2020, 2:30 PMgildor
10/30/2020, 2:46 PMno you can'tThis is incorrect! Please check documentation of this function: The returned map preserves the entry iteration order.
mbonnin
10/30/2020, 2:47 PMmbonnin
10/30/2020, 2:48 PMLists
I think, it's a bit more verbose/less optimal I think but at least it'll make it explicit that the order is keptNir
10/30/2020, 2:58 PMNir
10/30/2020, 2:58 PM