Skip to content

Files

Latest commit

 

History

History
31 lines (19 loc) · 776 Bytes

ArrayPrimitive.md

File metadata and controls

31 lines (19 loc) · 776 Bytes

Pattern: Use of Array<Primitive>

Issue: -

Description

Using Array<Primitive> leads to implicit boxing and performance hit. Prefer using Kotlin specialized Array Instances.

As stated in the documention, Kotlin has specialized arrays to represent primitive types without boxing overhead, such as IntArray, ByteArray and so on.

Example of incorrect code:

fun function(array: Array<Int>) { }

fun returningFunction(): Array<Double> { }

Example of correct code:

fun function(array: IntArray) { }

fun returningFunction(): DoubleArray { }

Further Reading