Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yeah but the example code looks like multiple expressions?


Those might be functions that alter context of the closure rather than being returned. Or it might be some Swift compiler magic?


So far I found out it's implemented via parameter attribute [1]

[1]: https://developer.apple.com/documentation/swiftui/viewbuilde...


More details in the proposal [1]:

> the basic idea is that we take the "ignored" expression results of a block of statements — including in nested positions like the bodies of if and switch statements — and build them into a single result value that becomes the return value of the current function.

[1]: https://forums.swift.org/t/pitch-function-builders/25167


Ouch, that’s pretty awful…


They look like initializers. Functions are lower-case by convention in Swift.


That is convention, but there’s no need to follow it ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: