anlex N
03/26/2024, 6:07 AMemptyList<String>() have compared to listOf<String>()?
Thread in Slack ConversationRuckus
03/26/2024, 6:08 AManlex N
03/26/2024, 6:14 AMRuckus
03/26/2024, 6:15 AManlex N
03/26/2024, 6:16 AMRuckus
03/26/2024, 6:20 AMemptyList is a singleton, so there is only one. Not one per package, or one per module, or one per class, just one total.Rob Elliot
03/26/2024, 8:10 AMlistOf<String>() is an alias to `emptyListString()`:
public inline fun <T> listOf(): List<T> = emptyList()
So in practice there is no difference, they return exactly the same instance.anlex N
03/26/2024, 8:18 AMpublic inline fun <T> listOf(): List<T> = emptyList(). kotlin source code?Rob Elliot
03/26/2024, 8:28 AMRob Elliot
03/26/2024, 8:28 AManlex N
03/26/2024, 8:44 AMKlitos Kyriacou
03/26/2024, 10:25 AMsite:<https://kotlinlang.org/api> listOf - then click on the relevant link, which takes you to https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/list-of.html and from there, click on the "source code" link.