getOrNull

fun <T> List<T>.getOrNull(index: Int): T?(source)

Returns the element at index, or null when the index is outside this list.

Negative indexes and indexes at or beyond size return null without calling List.get. For nullable element types, null can also be a stored element.

Receiver

list to read.

Return

the element at index, or null when no such index exists.

Parameters

index

zero-based element index.

See also