JadenGeller / Comparator

Swift type for determining the ordering of two Comparable values

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Swift type for determining the ordering of two Comparable values

License:MIT License


Languages

Language:Swift 100.0%