[swift-evolution] [proposal] extra if syntax

Charles Srstka cocoadev at charlessoft.com
Tue May 10 18:43:42 CDT 2016


> On May 10, 2016, at 1:10 PM, MobileSoft (Piotr) via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I think that should be added new ‘postfix’ if syntax:
> a = 5 if b == x
> 
> the code will be better readable. For example:
> 
> a = 5 if b == x
> c = 6
> d = 8
> e = 10 if y == true
> f = 12
> 
> in this situation all assigns are on the same, left side.

What’s wrong with:

a = (b == x ? 5 : whateverElseBShouldBe)
c = 6
d = 8
e = (y ? 10 : whateverElseEShouldBe)
f = 12

Charles

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


More information about the swift-evolution mailing list