copyOfRange

Common
Native
1.0
fun <T> Array<T>.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): Array<T>
JVM
1.0
@JvmName("copyOfRangeInline") fun <T> Array<T>.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): Array<T>
JS
1.1
fun <T> Array<out T>.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): Array<T>
Common
JS
Native
1.0
fun ByteArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ByteArray
JVM
1.0
@JvmName("copyOfRangeInline") fun ByteArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ByteArray
Common
JS
Native
1.0
fun ShortArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ShortArray
JVM
1.0
@JvmName("copyOfRangeInline") fun ShortArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ShortArray
Common
JS
Native
1.0
fun IntArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): IntArray
JVM
1.0
@JvmName("copyOfRangeInline") fun IntArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): IntArray
Common
JS
Native
1.0
fun LongArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): LongArray
JVM
1.0
@JvmName("copyOfRangeInline") fun LongArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): LongArray
Common
JS
Native
1.0
fun FloatArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): FloatArray
JVM
1.0
@JvmName("copyOfRangeInline") fun FloatArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): FloatArray
Common
JS
Native
1.0
fun DoubleArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): DoubleArray
JVM
1.0
@JvmName("copyOfRangeInline") fun DoubleArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): DoubleArray
Common
JS
Native
1.0
fun BooleanArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): BooleanArray
JVM
1.0
@JvmName("copyOfRangeInline") fun BooleanArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): BooleanArray
Common
JS
Native
1.0
fun CharArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): CharArray
JVM
1.0
@JvmName("copyOfRangeInline") 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), must be in 0..array.size

toIndex - the end of the range (exclusive), must be in fromIndex..array.size

Common
JVM
JS
Native
1.3
@ExperimentalUnsignedTypes fun UIntArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): UIntArray
@ExperimentalUnsignedTypes fun ULongArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): ULongArray
@ExperimentalUnsignedTypes fun UByteArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): UByteArray
@ExperimentalUnsignedTypes fun UShortArray.copyOfRange(
    fromIndex: Int,
    toIndex: Int
): UShortArray

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

Parameters

fromIndex - the start of the range (inclusive), must be in 0..array.size

toIndex - the end of the range (exclusive), must be in fromIndex..array.size