Returns an element at the given index or null
if the index is out of bounds of this array.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
val list = listOf(1, 2, 3)
println(list.elementAtOrNull(0))
println(list.elementAtOrNull(2))
println(list.elementAtOrNull(3))
val emptyList = emptyList<Int>()
println(emptyList.elementAtOrNull(0))
}
Target: JVMRunning on v.2.1.20
Returns an element at the given index or null
if the index is out of bounds of this collection.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
val list = listOf(1, 2, 3)
println(list.elementAtOrNull(0))
println(list.elementAtOrNull(2))
println(list.elementAtOrNull(3))
val emptyList = emptyList<Int>()
println(emptyList.elementAtOrNull(0))
}
Target: JVMRunning on v.2.1.20
Returns an element at the given index or null
if the index is out of bounds of this list.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
val list = listOf(1, 2, 3)
println(list.elementAtOrNull(0))
println(list.elementAtOrNull(2))
println(list.elementAtOrNull(3))
val emptyList = emptyList<Int>()
println(emptyList.elementAtOrNull(0))
}
Target: JVMRunning on v.2.1.20
Returns an element at the given index or null
if the index is out of bounds of this array.
Since Kotlin
1.3Samples
import kotlin.test.*
fun main() {
val list = listOf(1, 2, 3)
println(list.elementAtOrNull(0))
println(list.elementAtOrNull(2))
println(list.elementAtOrNull(3))
val emptyList = emptyList<Int>()
println(emptyList.elementAtOrNull(0))
}
Target: JVMRunning on v.2.1.20