LastOrNull

The opposite of firstOrNull,  this function returns the last item that satisfies the predicate or null in case of no items matching the predicate:

val numbers = listOf(1, 2, 3, 4, 5)
val lastLargerThan10 = numbers.lastOrNull { 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.17.179.239