Algus

array types

Arrays are much asic than the collection types. They don’t support resizing, are always mutable, and overwrite values in the array instead of making room for them.

fun displayAges(ages: IntArray){ ... }

val ages = intArrayOf(18,21,16,30)
displayAges(ages)

// Converting listOf

val ages = listOf(18,21,16,30)
displayAges(ages.toIntArray())
Array typeCreation Function
IntArrayintArrayOf
DoubleArraydoubleArrayOf
LongArraylongArrayOf
ShortArrayshortArrayOf
ByteArraybyteArrayOf
FloatArrayfloatArrayOf
BooleanArraybooleanArrayOf
ArrayarratOf

💡 Array compiles to a primitive array that holds any reference type.