Skip to content
Advertisement

What is the `it` in Kotlin lambda body?

For example in these two following codes:

JavaScript

and

JavaScript

In this code what does it mean?

Advertisement

Answer

it variable is an implicit parameter in lambda.

One other helpful convention is that if a function literal has only one parameter, its declaration may be omitted (along with the ->), and its name will be it:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement