Skip to content

Instantly share code, notes, and snippets.

@vinivendra
Last active January 31, 2017 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinivendra/4ce5b8b502ec57b2ce3c to your computer and use it in GitHub Desktop.
Save vinivendra/4ce5b8b502ec57b2ce3c to your computer and use it in GitHub Desktop.
precedencegroup ComparisonChainPrecedence {
higherThan: ComparisonPrecedence
associativity: right
}
//
infix operator ≤: ComparisonChainPrecedence
func ≤ (left: Int, right: Int) -> Int {
if left < right {
return left
} else {
return Int.min
}
}
//
infix operator ≤=: ComparisonChainPrecedence
func ≤= (left: Int, right: Int) -> Int {
if left <= right {
return left
} else {
return Int.min
}
}
//
infix operator ≥: ComparisonChainPrecedence
func ≥ (left: Int, right: Int) -> Int {
if left > right {
return left
} else {
return Int.max
}
}
//
infix operator ≥=: ComparisonChainPrecedence
func ≥= (left: Int, right: Int) -> Int {
if left >= right {
return left
} else {
return Int.max
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment