[swift-evolution] ternary operator ?: suggestion

Andrey Tarantsov andrey at tarantsov.com
Fri Dec 11 19:36:12 CST 2015

> I think replacing with `let foo` and scopes lengthens, emphasizes, and draws attention to a very minor detail, de-emphaizing and obscuring the main idea of the function.


> How about:
> let v = if condition then “A" else “B"

I don't think introducing a separate "then" keyword is a good idea, two subtly different kinds of IFs would be confusing.

I guess you meant:

let v = if condition { "A" } else { "B" }

That's acceptable to me, although might not be any more readable, and feels slightly inferior to:

let v = (condition ? "A" : "B")


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151212/87813fb8/attachment.html>

More information about the swift-evolution mailing list