indices
Начиная с Kotlin: 1.0
val <T> Array<out T>.indices: IntRange
val ByteArray.indices: IntRange
val ShortArray.indices: IntRange
val IntArray.indices: IntRange
val LongArray.indices: IntRange
val FloatArray.indices: IntRange
val DoubleArray.indices: IntRange
val BooleanArray.indices: IntRange
val CharArray.indices: IntRange
Возвращает диапазон допустимых индексов массива.
val UIntArray.indices: IntRange
val ULongArray.indices: IntRange
val UByteArray.indices: IntRange
val UShortArray.indices: IntRange
Возвращает диапазон допустимых индексов массива.
val Collection<*>.indices: IntRange
Возвращает IntRange допустимых индексов этой коллекции.
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val empty = emptyList<Any>()
println("empty.indices.isEmpty() is ${empty.indices.isEmpty()}") // true
val collection = listOf('a', 'b', 'c')
println(collection.indices) // 0..2
//sampleEnd
}
© 2010–2026 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/indices.html