Higher-order Functions (part-II)
Learn about lambda expressions in Kotlin.
We'll cover the following
Lambda expressions
In the previous lesson, we started by trying to understand the following line of code:
var lengths = strings.map {it.length}
But what about the strange curly braces?
To introduce the curly braces, we need to ‘inline’ our transformation function.
Like any other variable, we can inline getLengthOfString
by replacing that reference directly with its true value. In this case, this will be the transformation function itself. This is how it’s done:
Get hands-on with 1400+ tech skills courses.