/Comparator

Swift type for determining the ordering of two Comparable values

Primary LanguageSwiftMIT LicenseMIT

Comparator

Easily match on the ordering of two Comparable values.

switch Ordering(a, b) {
  case .ascending:  print("It's going up!")
  case .same:       print("They're no different.")
  case .descending: print("Down they go!")
}

You can also use the convenient operator a <=> b to create an Ordering value.