Single

This function scans the entire collection and returns the item that satisfies the predicate. If no items or more than one item match the predicate, then it throws an Exception.

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

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