<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Chris,<div class=""><br class=""></div><div class="">Thanks for bringing this idea to the list.</div><div class=""><br class=""></div><div class="">Is NSDate really the only thing that we want to conform to comparable, or is there a set of classes which should do so? I’d like to think about the larger set of consequences here (and if possible, deal with one coherent answer for all of Foundation rather than do these classes one at a time).<div class=""><div class=""><br class=""></div><div class="">- Tony</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 5, 2015, at 3:36 PM, Chris Amanse via swift-corelibs-dev <<a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hello Swift Developers,<div class=""><br class=""></div><div class="">I think it's a good idea to conform NSDate to the Comparable protocol, so instead of using:</div><div class=""><br class=""></div><div class="">if someDate.compare(today) == .OrderedAscending { }</div><div class=""><br class=""></div><div class="">Developers can easily compare using compare dates using comparison operators:</div><div class=""><br class=""></div><div class="">if someDate < today { }</div><div class=""><br class=""></div><div class="">In my opinion, the code is still readable if developers use comparison operators on NSDates.</div><div class=""><br class=""></div><div class="">Here's a quick implementation from my swift-corelibs-foundation fork: <a href="https://github.com/chrisamanse/swift-corelibs-foundation/commit/3c4eff643c5271de5bec2461798051347be13916" class="">https://github.com/chrisamanse/swift-corelibs-foundation/commit/3c4eff643c5271de5bec2461798051347be13916</a></div><div class=""><br class=""></div><div class="">Thank you.</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=U7z7oSqRMSwdl2rYt9JJ4zIFaeg4R-2FxExg9xndDuCbwubPQSgA-2BzXy1o-2FW-2BbadaFYFQKc49KZNc8-2Bhm-2Bve7MsFXaVjMk3bYwD-2BuMDedGGtK9letYRlNnQOD5wcEuL-2BLVMeJ0IdIQ5gTVD2BPWoBuSQeXGBPNYOZjO1khjdjNwQZSjZInQ-2FUFgGc-2BOaNkKgvklAxkJO4boWVkFdD5iW-2BrQ8LvozsLCPhfmCGAUQ9Clks-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-corelibs-dev mailing list<br class=""><a href="mailto:swift-corelibs-dev@swift.org" class="">swift-corelibs-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-corelibs-dev<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>