Last active
August 29, 2015 14:13
-
-
Save chakrit/04688ff895fa34a1d4bd to your computer and use it in GitHub Desktop.
Swift ranges weirdness.
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
import Foundation | |
let a = 1 | |
let b = 10 | |
func thisFailsToCompile() -> Bool { | |
// type 'Range<Int>' does not conform to protocol 'IntervalType' | |
let range = a..<b | |
return range ~= 3 | |
} | |
func butThisIsOk() -> Bool { | |
return a..<b ~= 3 | |
} | |
func thisIsAlsoOk() -> Bool { | |
let range: HalfOpenInterval<Int> = a..<b | |
return range ~= 3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment