Skip to content

Instantly share code, notes, and snippets.

@Nadohs
Last active August 29, 2015 14:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Nadohs/98c5db1f4125ce27309d to your computer and use it in GitHub Desktop.
range compare operator
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