4 ms·
This is a very common idiom in Scala. Function definition is slightly different, but usage is the same.
by vvillena 6y ago
This is a very common idiom in Scala. Function definition is slightly different, but usage is the same.
- agumonkey 6y agoAny example ? or an idiom name I can google ?
- swsieber 6y agoGroovy also does it. I have no idea what the name is though: https://mrhaki.blogspot.com/2009/11/groovy-goodness-passing-closures-to.html?m=1 https://mrhaki.blogspot.com/2009/11/groovy-goodness-passing-...
- jayrhynas 6y agoSwift calls it trailing closure syntax
- agumonkey 6y agoOk so it's an explicit parameter, the function is just ~curried so you can just write it nicely.
- matsemann 6y agoNot sure about the exact name. But kotlin also has "function with receiver" that together with this makes it very easy to write almost a custom domain language on top of kotlin.
- matsemann 6y agoCan't edit, but here's an explanation https://kotlinlang.org/docs/reference/type-safe-builders.html https://kotlinlang.org/docs/reference/type-safe-builders.htm...