Idiomatic way to transform map in kotlin?

I don’t think one person’s opinion counts as idiomatic, but I’d probably use

// transform keys only (use same values)
hashMap.mapKeys { it.key.uppercase() }

// transform values only (use same key) - what you're after!
hashMap.mapValues { it.value.uppercase() }

// transform keys + values
hashMap.entries.associate { it.key.uppercase() to it.value.uppercase() }

Note: or toUpperCase() prior to Kotlin 1.5.0

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)