The opposite of the first function, last returns the last item that satisfies the predicate or throws the NoSuchElementException:
val numbers = listOf(1, 2, 3, 4, 5)
val lastEven = numbers.last { n -> n % 2 == 0 }
The opposite of the first function, last returns the last item that satisfies the predicate or throws the NoSuchElementException:
val numbers = listOf(1, 2, 3, 4, 5)
val lastEven = numbers.last { n -> n % 2 == 0 }
18.191.198.227