[swift-evolution] Proposal: Optional Binding Shorthand Syntax

Tyler Mandry tmandry at gmail.com
Sun Dec 6 15:38:58 CST 2015


What isn't clear to me from Chris's or John's comments is why the `if let
x? = foo` syntax was taken away. Was it for backward-compatibility? To me,
this syntax does have special syntactic support, and also seems to make it
clearer what's going on. It's also analogous to Swift's type inference for
generic <T?> types, for example:

   func doSomething<T? where T: Equatable>(x: T?) -> T { ... }

Note the T? in brackets. If I pass an Int? to doSomething, the type is
"unwrapped" and T becomes Int. It seems like `if let x? = foo` would follow
the same pattern.

Was the syntax taken away for reasons unlikely to change, or is it up for
discussion? :)

-- 
Tyler Mandry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151206/fc1b6148/attachment.html>


More information about the swift-evolution mailing list