Created
February 25, 2015 17:27
-
-
Save wjlafrance/24c1867a96f24874f6b3 to your computer and use it in GitHub Desktop.
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
class IncrementorSequence : SequenceType { | |
func generate() -> GeneratorOf<Int> { | |
var value = 0 | |
return GeneratorOf<Int> { | |
return value++ | |
} | |
} | |
} | |
let words = ["The", "quick", "brown", "fox"] | |
for (index, word) in zip(IncrementorSequence(), words) { | |
println("index \(index) word \(word)") | |
} | |
for i in 0..<words.count { | |
println("index \(i) word \(words[i])") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you are looking for
enumerate()