Programming paths / Kotlin

Kotlin learning path

Use Kotlin’s null safety, data types, and coroutines to create concise Android and backend applications.

Starter lesson

Filter immutable task data

A data class describes a value, while collection operations can produce a new result without mutating the source list.

data class Task(val title: String, val ready: Boolean)

fun main() {
    val tasks = listOf(
        Task("Ship feature", true),
        Task("Update docs", false)
    )

    val readyTitles = tasks
        .filter(Task::ready)
        .map(Task::title)

    println(readyTitles)
}

What to expect

[Ship feature]

Key idea: Small immutable models and collection operations make application rules easier to test.

← Browse all programming paths