August 2018
Beginner
178 pages
4h 56m
English
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 }
Read now
Unlock full access