Hi, in which cases should I use arrays instead of ...
# getting-started
a
Hi, in which cases should I use arrays instead of lists ?
e
performance, but we are talking about special corner cases
r
Pretty much just interop with legacy APIs that require Arrays (very common in Java APIs)
Generally you don't want to be building new kotlin APIs that force you to use Arrays
Except ByteArray, that's still pretty common for performance
a
Should I use them for DoubleArrays and IntArrays ?
r
Again, depends on the application, how large you expect them to be and how much performance matters. If it's something like ARGB pixel values for image processing an array might make sense (although that may also be enforced by interop if you're using an image processing library)
a
Okay I see, thanks !
a
Working with primitives and arrays together happens often because usually if you're working with primitives instead of higher level data elements you're doing it for performance reasons in the first place
a
For a game where I do some big calculations on coordinates or something and I store a lot of numbers in a list, should I use then an array ?
e
if the size is fixed and known a priori, you may use it
a
Okay it's very specific I see