FirstOrNull

This function is the same as first, but if no item satisfies the predicate then null is returned instead of throwing an exception:

val numbers = listOf(1, 2, 3, 4, 5)
val firstLargerThan10 = numbers.firstOrNull { n -> n > 10 }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.55.198