copyInto

fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, kapacity: Kapacity): ByteArray
fun UByteArray.copyInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, kapacity: Kapacity): UByteArray
fun Array<Byte>.copyInto(destination: Array<Byte>, destinationOffset: Int = 0, startIndex: Int = 0, kapacity: Kapacity): Array<Byte>
fun Array<UByte>.copyInto(destination: Array<UByte>, destinationOffset: Int = 0, startIndex: Int = 0, kapacity: Kapacity): Array<UByte>

Copies up to the specified kapacity of bytes from this array into the destination array.

Zero Allocation & Safe Bounds: This operation mutates the provided destination array directly without allocating new memory. It safely clamps the number of bytes copied to prevent IndexOutOfBoundsException. The actual number of bytes transferred will be the minimum of: the requested kapacity, the available data in this source array after startIndex, or the available space in the destination array after destinationOffset.

Return

The original destination array, allowing for fluent method chaining.

Parameters

destination

The array to write the copied data into.

destinationOffset

The index in the destination array to begin writing at. Defaults to 0.

startIndex

The index in this source array to begin reading from. Defaults to 0.

kapacity

The maximum amount of data to copy.