get
Начиная с Kotlin: 1.1
abstract operator override fun get(index: Int): E
Возвращает элемент списка с указанным индексом.
Исключения
Примеры
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
println(list[0]) // 1
println(list[2]) // 3
// list[3] // will fail with IndexOutOfBoundsException
//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/-abstract-list/get.html