Despite being interesting and existing in other languages, I believe in Swift 
this could lead to weird declarations like

let x = 5 if b == 2

Would that mean the variable doesn't get declared if the condition fails? If it 
gets declared, which will be its value?  The types of statements that would 
allow this construction would have to be limited. Moreover, although this would 
allow for very readable semantics, the condition is not immediately seen and 
could lead to misunderstanding of the code.

I believe the current if and ?: syntaxes solve this issue and other needs using 
a very clean and readable syntax and don't really see a strong point in adding 
this new construct to the language.

> On 10 May 2016, at 3:10 pm, MobileSoft (Piotr) via swift-evolution 
> <swift-evolution@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.
> 
> regards
> piotr
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to