[swift-evolution] [Proposal] function "return" optional keyword.

Matthew Johnson matthew at anandabits.com
Sat Dec 19 10:14:05 CST 2015


Not sure if I like this or not, but if we do adopt it I think it should be consistent with the rule for closures.  Following the current rule for closures, this would only apply to single expression functions.  I think I could support that.  


> On Dec 19, 2015, at 9:53 AM, Dennis Lysenko via swift-evolution <swift-evolution at swift.org> wrote:
> 
> This is very nice for writing lazy var definitions and single-line computed properties as well. +1 from me.
> 
> 
> On Sat, Dec 19, 2015, 8:30 AM Craig Cruden via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> 
> When writing short functional code in a function it would be nice if the return keyword were an optional keyword. 
> 
> Just return the last evaluated expression.
> 
> 
> i.e.
> 
>     func flipFunc<T, U>(arg1: T, arg2: U) -> (U, T) {
>         (arg2, arg1)
>     }
> 
> 
> The keyword return would still be there for breaking out of a function.
> 
> _______________________________________________
> 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>
>  _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151219/c6a07d9e/attachment.html>


More information about the swift-evolution mailing list