Avatar
↑の defer の挙動の違いは Error Handling Rationale and Proposal に書かれてる。 Swift は意図的にスコープ単位に改変して導入した。 Overall, I think it is better to use a Go-style defer than a Java-style try ... finally. ... Unlike Go, I think this should be tied to scope-exit, not to function-exit. https://github.com/apple/swift/blob/master/docs/ErrorHandlingRationale.rst#clean-up-actions-1
The Swift Programming Language. Contribute to apple/swift development by creating an account on GitHub.