Created
February 3, 2016 16:55
-
-
Save Ben-G/82e2b708652f3c654e48 to your computer and use it in GitHub Desktop.
"Infinite" loop with ForwardIndexType and `distanceTo`
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
struct AIndex: ForwardIndexType { | |
let index: Int | |
func successor() -> AIndex { | |
return AIndex(index: self.index + 1) | |
} | |
} | |
func == (lhs: AIndex, rhs: AIndex) -> Bool { | |
return lhs.index == rhs.index | |
} | |
// Sit and wait... | |
AIndex(index: 999).distanceTo(AIndex(index: 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment