copyOfRange

Common
inline fun UIntArray.copyOfRange(fromIndex: Int, toIndex: Int): UIntArray
inline fun ULongArray.copyOfRange(fromIndex: Int, toIndex: Int): ULongArray
inline fun UByteArray.copyOfRange(fromIndex: Int, toIndex: Int): UByteArray
inline fun UShortArray.copyOfRange(fromIndex: Int, toIndex: Int): UShortArray

Returns a new array which is a copy of the specified range of the original array.

Since Kotlin

1.3

Parameters

fromIndex

the start of the range (inclusive) to copy.

toIndex

the end of the range (exclusive) to copy.

Throws

if fromIndex is less than zero or toIndex is greater than the size of this array.

Common
fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>
fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray
fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray
fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray
fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray
fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray
fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray
fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray
fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray

Returns a new array which is a copy of the specified range of the original array.

Parameters

fromIndex

the start of the range (inclusive) to copy.

toIndex

the end of the range (exclusive) to copy.

Throws

if fromIndex is less than zero or toIndex is greater than the size of this array.

@JvmName(name = "copyOfRangeInline")
inline fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>
@JvmName(name = "copyOfRangeInline")
inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray
@JvmName(name = "copyOfRangeInline")
inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray
@JvmName(name = "copyOfRangeInline")
inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray
@JvmName(name = "copyOfRangeInline")
inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray
@JvmName(name = "copyOfRangeInline")
inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray
@JvmName(name = "copyOfRangeInline")
inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray
@JvmName(name = "copyOfRangeInline")
inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray
@JvmName(name = "copyOfRangeInline")
inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray

Returns a new array which is a copy of the specified range of the original array.

Parameters

fromIndex

the start of the range (inclusive) to copy.

toIndex

the end of the range (exclusive) to copy.

Throws

if fromIndex is less than zero or toIndex is greater than the size of this array.

JS
fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>
fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray
fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray
fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray
fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray
fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray
fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray
fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray
fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray

Returns a new array which is a copy of the specified range of the original array.

Parameters

fromIndex

the start of the range (inclusive) to copy.

toIndex

the end of the range (exclusive) to copy.

Throws

if fromIndex is less than zero or toIndex is greater than the size of this array.

Native
fun <T> Array<T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T>
fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray
fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray
fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray
fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray
fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray
fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray
fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray
fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray

Returns a new array which is a copy of the specified range of the original array.

Parameters

fromIndex

the start of the range (inclusive) to copy.

toIndex

the end of the range (exclusive) to copy.

Throws

if fromIndex is less than zero or toIndex is greater than the size of this array.