val data = mapOf( 1 to "Desmond", 2 to "Mei Ru")val newData = data.entries.associate { (key, value) -> key to value}// or - performance of associate and associateBy should be equalval newData = data.entries.associateBy({(key, value) -> value}, {(key, value) -> key})// or - less efficientval newData = data.map { (key, value) -> value to key}.toMap()
Transform key only
val newData = data.mapKeys { (key, value) -> key - 1}
Transform values only
val newData = data.mapValues { (key, value) -> value.toUpperCase()}