carbaj0
05/30/2021, 4:32 PMMap<K,V>
using is Key?diesieben07
05/30/2021, 4:34 PMval newMap = map.toMutableMap()
newMap[key] = newValue
carbaj0
05/30/2021, 4:39 PMmyMap.map {
if(it.key == currentKey)
//modify his values
else
//return the original Map.Entry
}
diesieben07
05/30/2021, 4:40 PMcarbaj0
05/30/2021, 4:43 PMRuckus
05/30/2021, 4:51 PMval newMap = map + (key to value)
carbaj0
05/30/2021, 5:00 PMcarbaj0
05/30/2021, 5:01 PMfun <K, V> Map<K, V>.replace(key: K, values: V) =
toMutableMap().apply { this[key] = values }
carbaj0
05/30/2021, 5:01 PMMichael Böiers
06/01/2021, 9:02 AMwith
or copy
and make it return an immutable map again.carbaj0
06/01/2021, 9:50 AMfun <K, V> Map<K, V>.copy(key: K, values: V): Map<K, V> =
toMutableMap().apply { this[key] = values }
return an immutable map again explicitly it's really a good point