Karlo Lozovina
10/12/2021, 8:46 PMassociateWith
returns?hho
10/12/2021, 9:03 PMLinkedHashMap
is hardcoded in the stdlib. You could only use associateWithTo
to add the results to an existing (mutable) map of your choice.Karlo Lozovina
10/12/2021, 9:17 PMephemient
10/12/2021, 9:29 PMmapOf
, mutableMapOf
, and most Map-returning methods preserve insertion order, so in practice they are backed by LinkedHashMapassociateWithTo
(like other *To
methods) returns the collection itself, so you can write
val myMap = foo.associateWithTo(MyMapType()) { ... }
with the result of myMap: MyMapType