replace

@Nullable
open fun replace(@NotNull Key: @NotNull K, @NotNull function: @NotNull (V) -> V): @Nullable V

Replaces the entry for the specified key only if it is currently mapped to some value.

Return

the previous value associated with the specified key, or null if there was no mapping for the key.

Parameters

Key

key with which the specified value is associated

function

the function to compute a value