Add List.getOrNull()
windrunner414 opened this issue · comments
Yuxiang Liu commented
add a extension function getOrNull(int index)
on List to get element at the specified index safely. If out of bounds, return null.
It can work well with nnbd.
ref: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/get-or-null.html
alexeyinkin commented
This should be on Iterable
since elementAt
is there. Also it might be named elementAtOrNull
for consistency.