toMap method Null safety

KtMap<K, V> toMap()

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.

Implementation

KtMap<K, V> toMap() {
  if (size == 0) return emptyMap();
  return toMutableMap();
}