[swift-evolution] ternary operator ?: suggestion
Al Skipp
al_skipp at fastmail.fm
Tue Dec 15 11:11:13 CST 2015
> On 15 Dec 2015, at 16:18, Dennis Lysenko <dennis.s.lysenko at gmail.com> wrote:
>
> Also, +1 to removing ?: ternary in general. It does not match the atmosphere of Swift. Where you can write:
>
> self.x = a ? b : c
> self.y = a ? d : e
> self.z = a ? f : g
>
> You could just write
>
> if a {
> self.x = b
> self.y = d
> self.z = f
> } else {
> self.x = c
> self.y = e
> self.z = g
> }
>
> Now it's easier to scan for what changes when a is true. With if-expressions, this would scale even better to multiple conditions/declarations.
If the ternary operator is removed, but is not replaced with an equivalent expression, so that we must resort to ‘if’ statements, I will cry!
Al ðŸ˜
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151215/686cabec/attachment.html>
More information about the swift-evolution
mailing list