[swift-evolution] [Pitch] Introducing `Unwrappable` protocol

Greg Parker gparker at apple.com
Tue Mar 7 20:27:39 CST 2017


> On Mar 7, 2017, at 3:49 PM, Jaden Geller via swift-evolution <swift-evolution at swift.org> wrote:
> 
> It’s worth mentioning that the normal let binding can be used for pattern matching:
>   let (a, b, c) = foo()
> 
> This nicely parallels the existing case syntax:
>   if case let .blah(a, b, c) = bar() { … }
> It would feel inconsistent if the order switched when in a conditional binding.
> 
> I would prefer that `case` was removed to best mirror the normal syntax, requiring `?` or `.some` to be used for optionals
>   if let .blah(a, b, c) = bar() { … }
>   if let unwrapped? = wrapped { … }
>   if let .some(unwrapped) = wrapped { … }
> but I realize this is source-breaking, so I’m happy with the existing syntax.

We tried `if let unwrapped? = wrapped` some time ago. It was unbelievably unpopular. We changed it back.


-- 
Greg Parker     gparker at apple.com <mailto:gparker at apple.com>     Runtime Wrangler


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170307/b74cda6a/attachment.html>


More information about the swift-evolution mailing list