Array<Primitive>
KT-P1003In Kotlin, using Array<Primitive>
can lead to implicit boxing, which can reduce performance. Kotlin
provides specialized array classes for each primitive type (e.g., IntArray
, DoubleArray
, BooleanArray
, etc.), which
offer better performance and avoid unnecessary boxing and unboxing operations.
fun function(array: Array<Int>) {
// ..
}
Prefer specialized array classes over Array<Primitive>
.
fun function(array: IntArray) {
// ..
}