Hi! I have a `Map<Int, Pair<String, Role>>` that I...
# codereview
j
Hi! I have a
Map<Int, Pair<String, Role>>
that I want to update with a new pair at a given index. I have this code but I feel like one could do better. How would you implement it?
Copy code
private fun CompanyState.updateEmployees(
    index: Int,
    newValue: (Pair<String, Role>) -> Pair<String, Role>
): AddSceneState {
    val pair = employees[index] ?: return this
    val editableMap = employees.toMutableMap()
    editableMap[index] = newValue(pair)
    return copy(creatives = editableMap)
}
l