[swift-evolution] ternary operator ?: suggestion
Thorsten Seitz
tseitz42 at icloud.com
Sun Dec 13 08:53:12 CST 2015
> Am 13.12.2015 um 15:11 schrieb Marc Knaup via swift-evolution <swift-evolution at swift.org>:
>
> ** Keyword then **
> Making then a keyword would also cost us another word so that change needs to be carefully considered.
> In our large app I found just a single instance where then was used for a variable's name:
>
> func reloadConfigurationAndThen(then: () -> Void) { … }
> Promises use the word then rather extensively: https://promisesaplus.com <https://promisesaplus.com/>That’s a good point, Marc!
In that case we should probably refrain from introducing „then“ (or can the parser differentiate these usages, so that „then“ is still available for variables?
Rust is just using the statement form for the if-expression:
let x = if condition { … } else { … }
Rust allows having several statements in each block with the last having to be an expression which is used as value for the branch, effectively treating the { … } as closure and evaluating it for the branch executed.
Chris Lattner didn’t like using { … } in the if-expression, but I didn’t understand why, I have to admit.
-Thorsten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151213/f11d5db3/attachment.html>
More information about the swift-evolution
mailing list