Collections and Higher-Order Functions
Learn useful Kotlin collection functions such as map, filter and forEach.
Kotlin Code
Study the example and understand each part.
fun main() {
val marks = listOf(
45,
67,
82,
91,
38
)
val passed =
marks.filter {
it >= 50
}
passed.forEach {
println(it)
}
}
Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.
Key Concept
Functions such as filter(), map() and forEach() make collection processing concise and expressive.
Expected Output / Result
67 82 91
Finished this lesson?
Mark it complete to update your course progress.