Kotlin HashMap toMap()
Syntax & Examples


Syntax of HashMap.toMap()

There are 2 variations for the syntax of HashMap.toMap() extension function. They are:

1.
fun <K, V> Map<out K, V>.toMap(): Map<K, V>

This extension function returns a new read-only map containing all key-value pairs from the original map.

2.
fun <K, V, M : MutableMap<in K, in V>> Map<out K, V>.toMap( destination: M ): M

This extension function populates and returns the destination mutable map with key-value pairs from the given map.