[swift-evolution] [Pitch] Make `return` optional in computed properties for a single case

Matthew Johnson matthew at anandabits.com
Tue May 31 14:40:36 CDT 2016


> On May 31, 2016, at 2:36 PM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> Exactly.  You are allowed to omit `return` if the entire body only consists of `return some().expression`
> 
> Thats where the useless example comes in (but we don’t need this behavior at all):
> 
> func foo(boolean: Bool) {
> 
>     guard boolean else {}
> 
>     print("true“)
> 
> }
> 
> I made some changes to the proposal: https://github.com/DevAndArtist/swift-evolution/blob/single_expression_optional_return/proposals/nnnn-single-expression-optional-return.md <https://github.com/DevAndArtist/swift-evolution/blob/single_expression_optional_return/proposals/nnnn-single-expression-optional-return.md>
> 
> Please review it again. :)

That looks good.  You might want to include more complex expressions just to make it clear that this isn’t limited to literal-returning expressions.  Otherwise I think it covers it.  Thanks for putting this together!  I’ve wanted this for a long time… :)

> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160531/a374c7bc/attachment.html>


More information about the swift-evolution mailing list