https://kotlinlang.org logo
h

Hullaballoonatic

03/08/2020, 6:29 PM
Is there a good resource for understanding the usage differences between
List
and
Array
in Kotlin? Or
Array<Double>
and
DoubleArray
? Meaning when should you use one or the other, not what they literally are in terms of blocks of memory or the like.
l

Leon Linhart

03/08/2020, 6:34 PM
Array<Double>
is
Double[]
and
DoubleArray
is
double[]
. Prefer the latter whenever possible (i.e. not working with generics). Also generally speaking, only use
Array
instead of
List
for performance sensitive code.
👍 1
r

Ruckus

03/08/2020, 7:03 PM
When it comes to list vs array, the general rule of thumb is to use a list unless you need an array. If you don't know if you need an array, you likely don't.
👍 2