<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div style="direction: inherit;">Whenever I see such examples I feel like map is being abused because of some of its properties rather than this. Ring the best way to deal with optionals.</div><br>Sent from my iPhone</div><div><br>On 29 Aug 2016, at 11:26, Patrick Smith via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><span>A little nicer I think is:</span><br><span></span><br><span>if request?.httpVersion.map({ $0 < HTTPVersion(1.0) }) ?? true {</span><br><span></span><br><span>It’s very explicit what the fallback is too, the original’s ambiguity makes me uncomfortable.</span><br><span></span><br><span>BTW, did you want to be checking for <= 1.0? With HTTP 1.0, it’s opt in. <a href="https://en.wikipedia.org/wiki/HTTP_persistent_connection">https://en.wikipedia.org/wiki/HTTP_persistent_connection</a></span><br><span></span><br><span>Patrick</span><br><span></span><br><blockquote type="cite"><span>On 28 Aug 2016, at 1:20 PM, Kevin Ballard via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>As for optional comparisons making the code cleaner, I end up using them all over the place. The case that motivated my email looked something along the lines of</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span> if request?.httpVersion < HTTPVersion(1.0) {</span><br></blockquote><blockquote type="cite"><span> // no keepalive</span><br></blockquote><blockquote type="cite"><span> disconnect()</span><br></blockquote><blockquote type="cite"><span> }</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>This particular case could be trivially replaced with</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span> if request.map({ $0.httpVersion < HTTPVersion(1.0) }) ?? true {</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>but it’s uglier and harder to read.</span><br></blockquote><span></span><br><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>