Add sample of hashMapOf
This commit is contained in:
@@ -63,6 +63,17 @@ class Maps {
|
|||||||
assertPrints(map, "{1=x, 2=1.05}")
|
assertPrints(map, "{1=x, 2=1.05}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Sample
|
||||||
|
fun emptyHashMap() {
|
||||||
|
val map = hashMapOf<Int, Any?>()
|
||||||
|
assertTrue(map.isEmpty())
|
||||||
|
|
||||||
|
map[1] = "x"
|
||||||
|
map[2] = 1.05
|
||||||
|
// Now map contains something:
|
||||||
|
assertPrints(map, "{1=x, 2=1.05}")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,8 @@ public fun <K, V> mutableMapOf(vararg pairs: Pair<K, V>): MutableMap<K, V> =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an empty new [HashMap].
|
* Returns an empty new [HashMap].
|
||||||
|
*
|
||||||
|
* @sample samples.collections.Maps.Instantiation.emptyHashMap
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
|
|||||||
Reference in New Issue
Block a user