[swift-evolution] [Pitch] Make `return` optional in computed properties for a single case
Adrian Zubarev
adrian.zubarev at devandartist.com
Tue May 31 13:59:24 CDT 2016
+1. This is example *is not* a single expression code block. There are 3 expressions (the condition, the return value in the else block, and the primary return value).
The `else` block is a returning single expression block. I can’t show the `guard` example without any returning scope.
You said it yourself "everywhere in the language“. It’s not “everywhere“ if we would left out `guards` else-returning block.
If we’d allow this we could also write:
func test(boolean: Bool) {
guard boolean else {}
print("true")
}
This is useless and less readable.
But we already can do this with closures:
let nop = {} // useless
switch value {
...
default: {}() // do nothing
}
--
Adrian Zubarev
Sent with Airmail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160531/11c844d7/attachment.html>
More information about the swift-evolution
mailing list