Last active
February 5, 2024 22:40
-
-
Save el-hoshino/52287f710b48d3890a3151a888425fd5 to your computer and use it in GitHub Desktop.
AssociativeComparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precedencegroup AssociativeComparisonPrecedence { | |
associativity: left | |
higherThan: ComparisonPrecedence | |
lowerThan: NilCoalescingPrecedence | |
} | |
infix operator <: AssociativeComparisonPrecedence | |
infix operator <=: AssociativeComparisonPrecedence | |
public func < <V: Comparable>(lhs: V, rhs: V) -> (Bool, V) { | |
return ((lhs < rhs), rhs) | |
} | |
public func <= <V: Comparable>(lhs: V, rhs: V) -> (Bool, V) { | |
return ((lhs <= rhs), rhs) | |
} | |
public func < <V: Comparable>(lhs: (Bool, V), rhs: V) -> (Bool, V) { | |
return ((lhs.0 && lhs.1 < rhs), rhs) | |
} | |
public func <= <V: Comparable>(lhs: (Bool, V), rhs: V) -> (Bool, V) { | |
return ((lhs.0 && lhs.1 <= rhs), rhs) | |
} | |
public func < <V: Comparable>(lhs: (Bool, V), rhs: V) -> Bool { | |
return lhs.0 && (lhs.1 < rhs) | |
} | |
public func <= <V: Comparable>(lhs: (Bool, V), rhs: V) -> Bool { | |
return lhs.0 && (lhs.1 <= rhs) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = 2 | |
let b = 3 | |
if 1 < a < b <= 3 { | |
print("true") // true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment