ean5533
08/17/2016, 3:50 PMmapKeys
and mapValues
with a single pass? Here's what I have:
// 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
):
// 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() )