Feature request spread-dot operator

Spread-dot operator invokes action to each element in collection or simply makes map of it. It’s useful for quickly mapping collections and especially in the tests where you can compare sub set of collection. For example

persons.map { it.name } 

can be replaces with

persons*.name

More info and examples can be found in groovy documentation The Apache Groovy programming language - Operators

Why isn’t map enough?

2 Likes

If you check the examples in the list you’ll see that It’s convenient helper that can remove boilerplate code especially if you want to do few maps or forEach. It’s opinionated but groovy community is using it and code looks better so maybe there is place also in Kotlin.

In that case you can do a single map with a slightly longer lambda