[swift-evolution] ternary operator ?: suggestion

Charles Constant charles at charlesism.com
Wed Dec 16 21:30:32 CST 2015


I think I still prefer the original proposal to add a second syntax for
"switch" because it requires no learning curve at all. Even if I spent a
year without coding a single line of Swift, I'm sure when I came back to it
I'd remember the syntax for a "switch" assignment.

Having said that, I'd prefer sticking with a "?" since it's reminiscent of
a ternary, and regardless of parsing issues, it's easier to read if the
options are a tuple. So my second choice would be this variant of Paul's
suggestion:

    let a = sel ? (.Red: 1, .Green: 2, .Blue: 3)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/4d92e00f/attachment.html>


More information about the swift-evolution mailing list