[swift-evolution] Proposal Sketch: simplify optional unwrapping syntax

Tino Heth 2th at gmx.de
Tue Dec 22 12:08:45 CST 2015


> let color : Color? = getFavoriteColor()
> if color != nil {
> 	// Color is no longer an Optional
> }
well, I'd just write
if let color = getFavoriteColor() {…

This even more as the other solutions hide that "color" isn't the original "color" anymore inside the braces:
The first one was an Optional, the second one isn't.

Tino


More information about the swift-evolution mailing list