Since you mentioned do and defer: ``` func foo(wantsToBreak: Bool) { out: do { defer { print("Hello, world!") } guard wantsToBreak else { break out } } print("End of function.") } foo(wantsToBreak: true) // Output: Hello, world!\nEnd of function. foo(wantsToBreak: false) // Output: Hello, world!\nEnd of function. ``` Do you think this is confusing? At least it confused me in the fast. However, defer is still very useful. Even if I choose to use guard, defer and do, it will still look like the one with `if let`. Lots of blocks. The code should be straightforward without any brackets. See this example (since it’s a lot of code I rendered a PDF). |
code.pdf
Description: Adobe PDF document
|
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution