[swift-evolution] guard let x = x

Dany St-Amant dsa.mls at icloud.com
Wed Nov 2 06:58:28 CDT 2016


> Le 1 nov. 2016 à 14:42, Erica Sadun via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> With massive revisions. I've added Xiaodi Wu to author list. I've combined all unwrapping together. I've added a much more sensible approach (plus a bluesky one) for real world enumerations.
> 
> Gist with live updates here: https://gist.github.com/erica/db9ce92b3d23cb20799460f603c0ae7c
> 
> Send feedback, I will continue to revise.
> 

The proposal should describe the behaviour with nested-optional and with enum case providing optionals.

let x:Int?? = 42
guard let y = x, let z = y else { return }
// no final shadowing form currently exist for double unwrap

enum sample { case data(Int?) }
let x = sample.data(42)
guard case .data(let x) = x, let y = x else { return }
// x shadowed x, but still optional, cannot currently unwrap that optional as shadowing x

Not sure if the design should fully handle these cases, but their behaviour should be shown as to how they interact with the proposed syntax.

Regards
Dany
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161102/9da0797b/attachment.html>


More information about the swift-evolution mailing list