Skip to content
Guest
Kotlin & Android · Course Syllabus Show lessons
Kotlin Core · 8 min read · Intermediate

Collections, Extension Functions & Lambdas

Transform lists concisely with `filter`, `map`, `sortedBy`, and custom Kotlin extension functions.

What you'll learn

  • Chain `filter`, `map`, and `associateBy` cleanly
  • Write focused extension functions (`fun String.toSlug()`) for reusable helpers
  • Understand trailing lambda syntax (`items.forEach { ... }`)

Overview

Transform lists concisely with filter, map, sortedBy, and custom Kotlin extension functions.

Code Example

val completed = lessons
    .filter { it.isDone }
    .map { it.title }
    .sorted()

Key Takeaways

  • Chain filter, map, and associateBy cleanly
  • Write focused extension functions (fun String.toSlug()) for reusable helpers
  • Understand trailing lambda syntax (items.forEach { ... })

Quick Check

Check Your Understanding

Score: 0 / 1

1. What type does `listOf("A", "B")` return in Kotlin?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind