[swift-evolution] Proposal: Initialization should not be required in precondition(false) case.

Amir Michail a.michail at me.com
Fri Feb 12 10:32:24 CST 2016


> On Feb 12, 2016, at 11:29 AM, David Turnbull <dturnbull at gmail.com> wrote:
> 
> Use preconditionFailure() instead of precondition(false).
> 

That works! But I think precondition(false) should also work.

> -david
> 
> On Fri, Feb 12, 2016 at 7:59 AM, Amir Michail via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> For example:
> 
> let x:Int
> if … { x = 1 }
> else if … { x = 2 }
> else { precondition(false) } // no initialization needed
> 
> Similarly,
> 
> let x:Int
> switch ... {
> case …: x = 1
> case …: x = 2
> default: precondition(false) // no initialization needed
> }
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> 

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


More information about the swift-evolution mailing list