Is there any way to `mapKeys` and `mapValues` with...
# announcements
e
Is there any way to
mapKeys
and
mapValues
with a single pass? Here's what I have:
Copy code
// transform a Map<Int, Int> into a Map<String, String>
val intMap = mapOf(1 to 2, 3 to 4)
val stringMap = intMap.mapKeys { it.key.toString() }.mapValues { it.value.toString() }
Here is one example of what I envision as a single pass (non-existent function
mapEntries
):
Copy code
// transform a Map<Int, Int> into a Map<String, String>
val intMap = mapOf(1 to 2, 3 to 4)
val stringMap = intMap.mapEntries( { it.key.toString() }, { it.value.toString() )