bod
06/11/2020, 5:01 PMtddmonkey
06/11/2020, 5:42 PMMap<K, V>
-> Map<V, List<K>>
?bod
06/11/2020, 5:45 PMtddmonkey
06/11/2020, 6:37 PMmap.entries
.map { it.value to it.key }
.groupBy { it.first }
.mapValues { it.value.map { it.second } }
bod
06/11/2020, 6:52 PM.map
for Maps ? Something that takes a (k: K1, v:V1) -> Pair<K2, V2>
and returns a Map<K2, V2>
?java.util.Properties
to a Map<String, String>
and somehow this wasn't as trivial as I wanted, and I missed something like thisnkiesel
06/11/2020, 7:19 PMmapOf("A" to 1, "B" to 2, "C" to 3).map { it.value to it.key }.toMap()
should work for 1:1 mapsnils
06/11/2020, 8:14 PMmapOf(...).entries.associateBy({ it.value }) { it.key }
should also work for 1:1 mapsbod
06/12/2020, 6:44 AMBornyls Deen
06/12/2020, 9:58 AMMap
interface if this is functionality you find yourself requiring often š