0Pricing
Kotlin Academy · Lesson

it: The Implicit Parameter

Use the implicit 'it' parameter in single-parameter lambdas.

The Implicit it

When a lambda has exactly one parameter, you can omit declaring it and reference it as it. Saves typing for short pipelines.

it in forEach

The classic example: forEach passes each element as it.

fun main() {
    listOf(1, 2, 3).forEach { println(it) }
}

All lessons in this course

  1. What Is a Lambda? Syntax and Types
  2. Passing Lambdas to Functions
  3. it: The Implicit Parameter
  4. filter, map, and find on Collections
← Back to Kotlin Academy