fun valuesNotNull(map: MutableMap) { map.merge(1, "x") { old, new -> old + new } } fun valuesNullable(map: MutableMap) { map.merge(1, "x") { old, new -> old + new } map.merge(1, null) { old, new -> old + new } } fun valuesT(map: MutableMap, newValue: T) { map.merge(1, newValue) { old, new -> null } } fun valuesTNotNull(map: MutableMap, newValue: T) { map.merge(1, newValue) { old, new -> null } } fun valuesTNullable(map: MutableMap, newValue: T?) { map.merge(1, newValue) { old, new -> new } map.merge(1, newValue!!) { old, new -> new } }