https://kotlinlang.org logo
Title
y

yawkat

10/10/2019, 9:58 AM
is there a reason why emptyList has a type parameter and couldnt just return List<Nothing>?
d

diesieben07

10/10/2019, 10:01 AM
I think it's mostly convenience.
val emptyStringList: List<String> = emptyList()
vs.
val emptyStringList = emptyList<String>()
🤨 1
b

Burkhard

10/10/2019, 10:53 AM
There is an issue related to this: https://youtrack.jetbrains.com/issue/KT-1215, that would allow default type parameters. In this case
emptyList
could be defined as
fun emptyList<T = Nothing>()
. Andrey Breslav said that this is might be part of 1.4: https://discuss.kotlinlang.org/t/allow-typealias-to-have-the-same-name-as-generic-class/6789/9?u=wasabi375)