A trailing lambda places a lambda argument outside a Kotlin function call’s parentheses when it is the final argument. This often makes calls easier to read. section 5.1.3
Equivalent call forms
These forms mean the same thing: people.maxByOrNull({ p: Person -> p.age }) people.maxByOrNull() { p: Person -> p.age } people.maxByOrNull { p: Person -> p.age } When the lambda is the only argument, omit the empty parentheses. With multiple arguments, keep the lambda outside only when it is last. A call with two or more lambdas cannot move more than one outside. section 5.1.3
Listing 5.7 Passing a lambda outside of parentheses
people.joinToString(" ") { p: Person -> p.name }
A concise collection example shows a trailing lambda used as joinToString’s final transform argument. section 5.1.3
