[swift-evolution] Proposal: Optional Binding Shorthand Syntax

John McCall rjmccall at apple.com
Fri Dec 4 11:47:09 CST 2015


> On Dec 3, 2015, at 11:07 PM, Kevin Ballard <kevin at sb.org> wrote:
> 
> If we change anything based on this, I’d suggest the simpler change of removing `if let`/`while let` and renaming `if case`/`while case` to `if let`/`while let`. Since Swift now has the ? pattern type to mean optional binding, it means that all existing instances of 
> 
>     if let foo = bar {
> 
> become the almost-identical
> 
>     if let foo? = bar {

This is something we carefully considered after introducing the ? pattern, and in fact it was even implemented for a time.  The lesson we took from that experience was that optional-binding is really, really important, and it really is worthwhile to recognize that importance by giving it special syntactic support.

John.


More information about the swift-evolution mailing list