Add sample of hashMapOf

This commit is contained in:
keijumt
2019-04-09 16:49:23 +09:00
committed by ilya-g
parent cd6abcd4c9
commit 3f5d64e635
2 changed files with 13 additions and 0 deletions
@@ -63,6 +63,17 @@ class Maps {
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].
*
* @sample samples.collections.Maps.Instantiation.emptyHashMap
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly