<div dir="ltr"><div>It would be really helpful if you could describe the problem you're experiencing so I don't have to guess what it is from your example code.</div><div><br></div><div>Am I guessing right if I say that you want a change to Swift such that a switch initialisation can be 'force-unwrapped', such that if none of the cases apply, the app crashes, in a more explicit fashion?</div><div><br></div><div>I've written code like this, but I've tended towards 'default: fatalError()', which wouldn't be covered by your suggestion. 'precondition' isn't at fault here.</div><div><br></div><div>Just as a digression, I've just learned that 'precondition(false)' doesn't cause any immediately following code to receive the compiler warning 'will never be executed' that code in a 'if false { ... }' does. So that would be nice.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 12, 2016 at 3:59 PM, Amir Michail via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">For example:<br>
<br>
let x:Int<br>
if … { x = 1 }<br>
else if … { x = 2 }<br>
else { precondition(false) } // no initialization needed<br>
<br>
Similarly,<br>
<br>
let x:Int<br>
switch ... {<br>
case …: x = 1<br>
case …: x = 2<br>
default: precondition(false) // no initialization needed<br>
}<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div><br></div>