Alex
08/17/2022, 3:38 PMval aMap= mapOf("one" to 1,"two" to 2)
fun main() {
aMap.mapValues { (z,y)-> "$"+z;"$"+y }.forEach{z->println(z)}
}
Sam
08/17/2022, 3:39 PMaMap.entries.associate { (z, y) ->
"$"+z to "$"+y
}
mapValues
will only change the values in the map, even though it receives both the key and the value in its inputsassociate
you can instead use to
to join the two parts into a Pair
that’s returned in a single statementAlex
08/17/2022, 5:32 PM