Loading practice questions
What is the filter() function in Kotlin?
Correct Answer: A — Selects elements that meet a given condition
Explanation:
The filter() function in Kotlin returns a new collection containing only the elements that meet the specified condition.
val numbers = listOf(1, 2, 3, 4)
val evenNumbers = numbers.filter { it % 2 == 0 } // [2, 4]