Add setOfNotNull function #KT-35851

This commit is contained in:
Abduqodiri Qurbonzoda
2020-02-13 14:46:14 +03:00
parent 5a4ce2aa4c
commit ce8e511b79
4 changed files with 45 additions and 0 deletions
@@ -334,6 +334,18 @@ class Collections {
assertPrints(set, "[1, 2, 4, 5]")
}
@Sample
fun setOfNotNull() {
val empty = setOfNotNull<Any>(null)
assertPrints(empty, "[]")
val singleton = setOfNotNull(42)
assertPrints(singleton, "[42]")
val set = setOfNotNull(1, null, 2, null, 3)
assertPrints(set, "[1, 2, 3]")
}
@Sample
fun emptyLinkedHashSet() {
val set: LinkedHashSet<Int> = linkedSetOf<Int>()