[swift-evolution] [proposal] extra if syntax

Austin Zheng austinzheng at gmail.com
Tue May 10 18:28:26 CDT 2016


This is vaguely similar to "if/else and switch as expressions" in the
Commonly Proposed list (
https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md),
and probably needs far more justification. (I would argue that it's worse,
since it's less expressive and, as a statement, cannot be composed.)

Austin

On Tue, May 10, 2016 at 4:25 PM, Ross O'Brien via swift-evolution <
swift-evolution at swift.org> wrote:

> In your example:
> a = 5 if b == x
>
> What value is assigned to 'a' if 'b' and 'x' are not equal?
>
> On Tue, May 10, 2016 at 7: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.
>>
>> regards
>> piotr
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> 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/20160510/7e86ad3e/attachment.html>


More information about the swift-evolution mailing list