Last active
August 29, 2015 14:28
-
-
Save Nadohs/98c5db1f4125ce27309d to your computer and use it in GitHub Desktop.
range compare operator
This file contains 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
func ~= <T:Comparable>(lhs:T,rhs:(T,T)) -> Bool{ | |
if lhs < rhs.0{ | |
return false | |
} | |
if lhs > rhs.1{ | |
return false | |
} | |
return true | |
} | |
let x = 5 | |
if 5 ~= (5, 7) { | |
print("in range!") | |
} | |
let res = 5 ~= (3, 5) | |
let res1 = 5 ~= (3, 4) | |
let res2 = 5 ~= (5, 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment