Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add List.getOrNull() #216

Open
windrunner414 opened this issue Sep 17, 2021 · 1 comment
Open

Add List.getOrNull() #216

windrunner414 opened this issue Sep 17, 2021 · 1 comment

Comments

@windrunner414
Copy link
Contributor

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
Copy link

This should be on Iterable since elementAt is there. Also it might be named elementAtOrNull for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants