Skip to content

Instantly share code, notes, and snippets.

@SebastianBoldt
Created October 16, 2016 09:00
Show Gist options
  • Save SebastianBoldt/27f8d3b61c7533ee76361ddcc91b25da to your computer and use it in GitHub Desktop.
Save SebastianBoldt/27f8d3b61c7533ee76361ddcc91b25da to your computer and use it in GitHub Desktop.
Compare Operators added by Swift 3 Converter
fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
switch (lhs, rhs) {
case let (l?, r?):
return l < r
case (nil, _?):
return true
default:
return false
}
}
fileprivate func > <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
switch (lhs, rhs) {
case let (l?, r?):
return l > r
default:
return rhs < lhs
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment