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 }
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 }
3.145.55.198