[swift-corelibs-dev] Proposal: Conforming NSDate to Comparable
Chris Amanse
christopheramanse at gmail.com
Sat Dec 5 17:36:52 CST 2015
Hello Swift Developers,
I think it's a good idea to conform NSDate to the Comparable protocol, so
instead of using:
if someDate.compare(today) == .OrderedAscending { }
Developers can easily compare using compare dates using comparison
operators:
if someDate < today { }
In my opinion, the code is still readable if developers use comparison
operators on NSDates.
Here's a quick implementation from my swift-corelibs-foundation fork:
https://github.com/chrisamanse/swift-corelibs-foundation/commit/3c4eff643c5271de5bec2461798051347be13916
Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20151205/115e5fd7/attachment.html>
More information about the swift-corelibs-dev
mailing list