Kotlin HashMap plus()
Syntax & Examples
Syntax of HashMap.plus()
There are 5 variations for the syntax of HashMap.plus() extension function. They are:
1.
operator fun <K, V> Map<out K, V>.plus( pair: Pair<K, V> ): Map<K, V>
This extension function creates a new read-only map by replacing or adding an entry to this map from a given key-value pair.
2.
operator fun <K, V> Map<out K, V>.plus( pairs: Iterable<Pair<K, V>> ): Map<K, V>
This extension function creates a new read-only map by replacing or adding entries to this map from a given collection of key-value pairs.
3.
operator fun <K, V> Map<out K, V>.plus( pairs: Array<out Pair<K, V>> ): Map<K, V>
This extension function creates a new read-only map by replacing or adding entries to this map from a given array of key-value pairs.
4.
operator fun <K, V> Map<out K, V>.plus( pairs: Sequence<Pair<K, V>> ): Map<K, V>
This extension function creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value pairs.
5.
operator fun <K, V> Map<out K, V>.plus( map: Map<out K, V> ): Map<K, V>
This extension function creates a new read-only map by replacing or adding entries to this map from another map.