addOrReplace

fun <V> Map<String, V>.addOrReplace(pair: Pair<String, V>): Map<String, V>

Returns a new map with the provided pair added, replacing any existing value for the key.

Return

a new map instance with pair applied

Parameters

pair

key-value pair to add or replace


fun <V> Map<String, V>.addOrReplace(pairs: List<Pair<String, V>>): Map<String, V>

Adds the provided key-value pairs to the map or replaces existing entries with the same keys.

This function creates a mutable copy of the original map, adds or replaces the entries, and then returns the updated map as a new instance, leaving the original map unmodified.

Return

a new map with the provided key-value pairs added or replaced

Parameters

pairs

a list of key-value pairs to add or replace in the map


Returns a new list where an item with the given key is added or replaced.

Return

updated list containing the provided pair

Parameters

pair

pair to add or replace by key


Adds or replaces key-value pairs in the current list with key-value pairs from the provided list. If a key from the provided list exists in the current list, the corresponding value is replaced. If ignoringCase is true, key matching is performed case-insensitively.

Return

A new list containing the updated key-value pairs with the specified additions or replacements.

Parameters

pairs

The list of key-value pairs to be added or used to replace existing pairs in the current list.

ignoringCase

A boolean flag indicating whether the key matching should ignore the case when determining replacements.