Skip to content

Instantly share code, notes, and snippets.

@wjlafrance
Created February 25, 2015 17:27
Show Gist options
  • Save wjlafrance/24c1867a96f24874f6b3 to your computer and use it in GitHub Desktop.
Save wjlafrance/24c1867a96f24874f6b3 to your computer and use it in GitHub Desktop.
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])")
}
@wjlafrance
Copy link
Author

Thanks @regnerjr! That's exactly what I was looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment