<div dir="ltr">On Mon, Dec 7, 2015 at 9:19 AM, Kevin Ballard via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><u></u>
<div><span class=""><div>Do you commonly write code where you don't understand the types you're working with?</div></span></div></blockquote><div><br></div><div>Here is one type of mistake that I made long after that I should have known better:</div><div><br></div><div><div><div> var x: Int?</div><div><br></div><div> // ...</div><div><br></div><div> switch x {</div><div> case let x where x < 0: // x is still Optional</div><div> default: // ...</div><div> }</div><div><br></div></div></div><div>Since you write 'if let' so often to unwrap, I kept forgetting that 'case let' does not, and that there is a special syntax for that: 'case let x?'.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><span class=""><div>Personally, I find the ability to compare optionals to be very valuable, almost as valuable as the ability to use == with optionals (which I doubt anyone will argue is a misfeature).</div></span></div></blockquote><div><br></div><div><div>I have been trying to come up with situations where you would want to compare two values, knowing that one or both may be nil, with <, <=, > or >=. Other than as for sorting, I can't think of much. I doubt the Swift team explicitly made this possible without good reason, so I must be missing something.</div><div><br></div><div>Could you please share some examples? It doesn't necessarily have to be code, just explain the context where this is valuable.</div><div><br></div></div></div></div></div>