get

expect abstract operator fun get(index: Int): E(source)

Returns the element at the specified index in the list.

Since Kotlin

1.0

Throws

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

Throws

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

Throws

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

Throws

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

Throws

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

Throws

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
}