[swift-evolution] ternary operator ?: suggestion
Andrey Tarantsov
andrey at tarantsov.com
Sat Dec 12 14:37:13 CST 2015
1. I would really hate to explain to someone when if needs a then and when it doesn't. That's the sort of inconsistency that shouldn't be added lightly.
2. As for
if cond (then-expr) (else-expr)
— this is definitely unreadable, and will cause problems. Even right now, if syntax vs expression syntax is ambiguous:
if let foo = foos.filter { $0.isBar } {
...
}
3. If we can somehow solve all of this, I think I'll be +1 for replacing (A ? B : C) with some sort of (if A then B else C).
4. Generally, I wonder how hard would it be for all statements to be usable as expressions? Why didn't Swift go that way from the start?
A.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151213/03042c20/attachment.html>
More information about the swift-evolution
mailing list