The following lambda expression operates on a class which was created outside of the lambda. I consider this clumsy. Is there a better way to this?
class Builder {
var searchTerms = listOf<String>()
fun build(whatever: String): Builder {
searchTerms = searchTerms + whatever
return this
}
}
fun main() {
val b = Builder()
val toSearch = listOf<String>("Anna", "Berta", "Carla")
toSearch.forEach{ e-> b.build(e)}
}