https://kotlinlang.org logo
#random
Title
h

hallvard

06/06/2018, 11:22 AM
These are lines 513-523 in the Maps.kt file as I see them in Idea:
Copy code
/**
 * Returns a new read-only map containing all key-value pairs from the original map.
 *
 * The returned map preserves the entry iteration order of the original map.
 */
@SinceKotlin("1.1")
public fun <K, V> Map<out K, V>.toMap(): Map<K, V> = when (size) {
    0 -> emptyMap()
    1 -> toSingletonMap()
    else -> toMutableMap()
}
Looks to me that a map with more than one key-value pair will be mutable after passing through this method...? What am I missing?