replace

inline fun <T> Iterable<T>.replace(item: T, replacement: T.() -> T): List<T>

Creates a copy of this with item replaced with whatever is returned by replacement.

item MUST be an item contained in the original list, or you will get an IndexOutOfBoundsException

Return

a list with all values of this with item replaced by replacement

See also