ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
What is the filter() function in Kotlin?
Correct Answer: A — Selects elements that meet a given condition
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]