inline fun <T : MutableCollection<A>, A> T.mutateAll(transform: (A) -> A): T

Applies transform to each element in the collection, reusing the same structure to keep them.

The mutable equivalent to

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() }

Note: this function removes in-place only if A is a MutableList, otherwise it clears the collection and re-adds the values.