| ▲ | ackfoobar 3 hours ago | |||||||
As noted in the article: > This feature does have some limitations, for instance when we have multiple nested function calls, but in those cases an explicit lambda expression is always still possible. I've also complained about that a while ago https://news.ycombinator.com/item?id=35707689 --- The solution is to delimit the level of expression the underscore (or dollar sign suggested in the article) belongs to. In Kotlin they use braces and `it`.
Then modifying the "hole in the expression" is easy. Suppose we want to subtract the first argument by 2 before passing that to `add`: | ||||||||
| ▲ | titzer 3 hours ago | parent [-] | |||||||
I think I like the explicit lambda better; I prefer to be judicious with syntactic sugar and special variable names. | ||||||||
| ||||||||