[swift-evolution] [Proposal] function "return" optional keyword.
Radosław Pietruszewski
radexpl at gmail.com
Sun Dec 20 14:29:27 CST 2015
I honestly don’t have a problem with having to say `return` inside functions. That’s not necessarily a -1, but I’m reluctant to say +1 when _even I_ don’t really have the problem with extra verbosity.
*However*, as others pointed out, having to type `return` is a bit tiring in the context of a computer property’s “get”:
> var twiceSomething: Int { self.something * 2 }
— Radek
> On 19 Dec 2015, at 14:30, Craig Cruden via swift-evolution <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
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151220/2c2cf06b/attachment.html>
More information about the swift-evolution
mailing list