What does this print?
fun main() {
val xs = listOf(8, 4, 1, 2)
println(xs.count { it > 5 })
}
Try it in the online Kotlin Playground →
[spoiler title="Solution"]
Answer:
1
Explanation:
count returns how many elements satisfy the predicate. Here only one (8) is greater than 5.
[/spoiler]