updateItem

inline fun <T> List<T>.updateItem(condition: (T) -> Boolean, function: (T) -> T): List<T>

Returns a new list with the first element that satisfies condition updated by function.

If no element matches condition, the original list is returned unchanged.

Return

A new List with the updated element, or the original list if no element matches.

Parameters

condition

A predicate to identify which element to update.

function

A transformation function applied to the matching element.