natpryce
04/24/2020, 11:36 AMemptyList() a generic function that returns a List<T>, instead of a non-generic function that returns a List<Nothing>? (Or even a constant or object?)diesieben07
04/24/2020, 11:36 AMval list = emptyList<String>()diesieben07
04/24/2020, 11:37 AMnatpryce
04/24/2020, 11:37 AMnatpryce
04/24/2020, 11:38 AMList<Nothing> and you did val list = emptyList() you’d still be able to pass list anywhere that expected a List<String> .natpryce
04/24/2020, 11:39 AMilya.gorbunov
04/24/2020, 12:47 PMNothing being explicitly mentioned in type arguments.
Second, if we had emptyList without generic parameters, it would be inconsistent with emptyMap that cannot declare its return type so that it could be assignable to any Map type parametrization due to its K type parameter being invariant.Zach Klippenstein (he/him) [MOD]
04/24/2020, 3:53 PMList<Nothing> under the hood.natpryce
04/24/2020, 5:07 PM