is it uncommon to use primitive array types (IntArray, BooleanArray etc) in Kotlin?
06/29/2019, 5:02 PM
As it was said, it's depends on your usecase, but in general because arrays are pretty limited in many aspects it's much more common to use List instead, and use arrays as performance optimization in some cases and usually do not expose it in public API
06/29/2019, 5:43 PM
Leaving the primitive variations aside, is Integer faster than ArrayList<Integer>?
06/30/2019, 4:59 AM
Integer is boxed, non-primitive array, so ArrayList<Integer> would be very close by performance, you just pay price of additional object
But int (or Kotlin IntArray) is better in terms of memory and allocation (get/set complexity is the same as List<Int>)
06/30/2019, 9:16 AM
I'm just trying to figure out what the point of Array<> is
when it's worse in pretty much every point
06/30/2019, 9:46 AM
Array<T> is just a platform primitive (part of memory with references to other objects), for example point of it to implement other, higher level collections, ArrayList (and many other data structures) are based on generic array
And this is cause quite rare usage of it. But it's still useful, after all you need some efficient way to keep list of references to other objects, but mostly it make sense for library authors