Curious why `emptyList()` is a `fun` and not a `va...
# stdlib
m
Curious why
emptyList()
is a
fun
and not a
val
? I can only guess it’s to do with generics
👌 2
i
It's a pure stylistic choice.
emptyList
could be a property of type
List<Nothing>
, but we decided that making it a function and thus having to specify its type parameter when it can't be inferred would be advantageous for reading code.
👍 3
Also this way it is consistent with
emptyMap
which on the contrary can't be a property, because of its invariant
K
type parameter.
👍 2