addOrReplace

fun addOrReplace(element: T & Any): T?

Adds or replaces an element in the list. If the element is already in the list (using equals), it will be replaced, otherwise it will be added.

If it is replaced, the old element will be returned, otherwise null will be returned.

Parameters

element

the element to add or replace. null is disallowed by the T & Any type.