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
}
Sam
08/17/2022, 3:40 PMmapValues
will only change the values in the map, even though it receives both the key and the value in its inputsSam
08/17/2022, 3:50 PMSam
08/17/2022, 3:51 PMassociate
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