<https://youtrack.jetbrains.com/issue/KT-25617>
# announcements
m
Although the list isn’t truly immutable, doesn’t this defeat the purpose of having an immutable list? If you need to modify it, it needs to be mutable.
j
They don't want to modify it. They want a copy with an updated element.
👍 4
💯 3
m
Doh! Guess I should read the whole thing before replying.
z
val updated: List<Int> = list.toMutableList().also { it[0] = 99 }
I think it's more explicit like that, so it's more obvious what you are doing with list and is also possible to do multiple changes.
j
Those arguments tend to apply to a lot of functions which make copies and mutate and shouldn't preclude the addition of convenience functions