David Kubecka
06/06/2024, 8:49 AMval l1 = listOf(1) + listOf(2)
val l2 = listOf(1, 2)
println(l1::class) // prints java.util.ArrayList
println(l2::class) // prints java.util.Arrays$ArrayList
Is this expected?
The reason why it bothers me is described here https://kotlinlang.slack.com/archives/C9EJFT6DB/p1717662793347379.Sam
06/06/2024, 8:51 AMlistOf()
is an implementation detail. In the unlikely event you care about the actual type of list, you can always instantiate the type you want directly. I explained more about the two different classes in my reply to your other thread.ephemient
06/06/2024, 8:57 AMlistOf(Unit)::class != listOf(*arrayOf(Unit))::class
this is an implementation detail you are not supposed to care about.David Kubecka
06/06/2024, 8:58 AM