> For the complete documentation index, see [llms.txt](https://gold.gitbook.io/kotlin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gold.gitbook.io/kotlin/collections/elements-operations/elementatornull.md).

# elementAtOrNull

해당하는 인덱스의 값을 반환한다. 없다면 null 을 반환한다

```kotlin
public inline fun <T> List<T>.elementAtOrNull(index: Int): T? {
    return this.getOrNull(index)
}

public fun <T> List<T>.getOrNull(index: Int): T? {
    return if (index >= 0 && index <= lastIndex) get(index) else null
}


val list = listOf(1, 2, 3, 4, 5)
println(list.elementAtOrNull(2))  // 3
println(list.elementAtOrNull(10))  // null
```
