Core API – Kotlin Programming Language (original) (raw)
get
expect abstract operator fun get(index: Int): E(source)
Returns the element at the specified index in the list.
Since Kotlin
1.0
if index is less than zero or greater than or equal to size of this list.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
assertEquals(1, list[0])
assertEquals(3, list[2])
// list[3] // will fail with IndexOutOfBoundsException
//sampleEnd
}actual abstract operator fun get(index: Int): E(source)
Returns the element at the specified index in the list.
Since Kotlin
1.1
if index is less than zero or greater than or equal to size of this list.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
assertEquals(1, list[0])
assertEquals(3, list[2])
// list[3] // will fail with IndexOutOfBoundsException
//sampleEnd
}actual abstract operator fun get(index: Int): E(source)
Returns the element at the specified index in the list.
Since Kotlin
1.0
if index is less than zero or greater than or equal to size of this list.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
assertEquals(1, list[0])
assertEquals(3, list[2])
// list[3] // will fail with IndexOutOfBoundsException
//sampleEnd
}actual abstract operator fun get(index: Int): E(source)
Returns the element at the specified index in the list.
Since Kotlin
1.3
if index is less than zero or greater than or equal to size of this list.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
assertEquals(1, list[0])
assertEquals(3, list[2])
// list[3] // will fail with IndexOutOfBoundsException
//sampleEnd
}actual abstract operator fun get(index: Int): E(source)
Returns the element at the specified index in the list.
Since Kotlin
1.8
if index is less than zero or greater than or equal to size of this list.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
assertEquals(1, list[0])
assertEquals(3, list[2])
// list[3] // will fail with IndexOutOfBoundsException
//sampleEnd
}actual abstract operator fun get(index: Int): E(source)
Returns the element at the specified index in the list.
Since Kotlin
1.8
if index is less than zero or greater than or equal to size of this list.
Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
val list = listOf(1, 2, 3)
assertEquals(1, list[0])
assertEquals(3, list[2])
// list[3] // will fail with IndexOutOfBoundsException
//sampleEnd
}