Spec-Zone.ru › Kotlin 2

indices

kotlin-stdlib/kotlin.collections/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

Возвращает диапазон допустимых индексов массива.


@ExperimentalUnsignedTypes
val UIntArray.indices: IntRange
@ExperimentalUnsignedTypes
val ULongArray.indices: IntRange
@ExperimentalUnsignedTypes
val UByteArray.indices: IntRange
@ExperimentalUnsignedTypes
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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API