5 ms·
> I think the way they do blocks is odd. I think that the braces should encapsulate the body of the block, not the variable expression as well I can't find an
by euroclydon 8y ago
> I think the way they do blocks is odd. I think that the braces should encapsulate the body of the block, not the variable expression as well
I can't find an example of what I imagine you're saying.
Can you link to an example from here the reference docs?
https://kotlinlang.org/docs/reference https://kotlinlang.org/docs/reference
- kllrnohj 8y agoI believe they are referring to the lambda syntax: https://kotlinlang.org/docs/reference/lambdas.html https://kotlinlang.org/docs/reference/lambdas.html // Lambdas are code blocks enclosed in curly braces. items.fold(0, { // When a lambda has parameters, they go first, followed by '->' acc: Int, i: Int -> print("acc = $acc, i = $i, ") val result = acc + i println("result = $result") // The last expression in a lambda is considered the return value: result })
- eropple 8y agoCorrect. It looks bizarre. Ruby at least sets off the arguments with pipes.