[swift-evolution] ternary operator ?: suggestion

thorsten at portableinnovations.de thorsten at portableinnovations.de
Sun Dec 6 15:35:28 CST 2015


I would prefer the expression to match the statement. The only difference would be that all parts that were statements now have to be expressions.

Therefore the switch-expression should simply look like follows:

let thisColor = switch thatColor {
         case .Red: .Green // must be an expression
         default: .Yellow      // must be an expression
     }

No returns needed in the case clauses.
Formatting this as a one-liner would just require adding semicolons (though I wouldn't recommend this).

-Thorsten


More information about the swift-evolution mailing list