[swift-evolution] ternary operator ?: suggestion

Rudolf Adamkovic salutis at me.com
Sun Dec 6 15:44:21 CST 2015


> On 06 Dec 2015, at 22:35, thorsten--- via swift-evolution <swift-evolution at swift.org> wrote:

> 
> 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.

+1

> 
> 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.

This actually looks great. One simple rule and zero new keywords.

Readable and simple to learn.

Fantastic!

> Formatting this as a one-liner would just require adding semicolons (though I wouldn't recommend this).
> 
> -Thorsten
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list