mutate All
Applies transform to each element in the collection, reusing the same structure to keep them.
The mutable equivalent to Collection.map.
val p = Person(name = "John", job = Job("Developer", listOf("Kotlin", "Training")))
val newP = p.copy { // mutates the job.teams collection in-place
job.teams.mutateAll { it.capitalize() }
}
Content copied to clipboard
Note: this function removes in-place only if A is a MutableList, otherwise it clears the collection and re-adds the values.