Created
January 18, 2020 10:11
-
-
Save JanGorman/23fecdb8e54e01db416c7f168ecd0ff8 to your computer and use it in GitHub Desktop.
Alternative to using .enumerated() and then having to add + 1 to the index for lists
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 Person { | |
let name: String | |
init(_ name: String) { | |
self.name = name | |
} | |
} | |
let people: [Person] = [.init("De Konig"), .init("Pollock"), .init("Rothko"), .init("Kandinsky")] | |
for (number, person) in zip(1..., people) { | |
print("\(number). \(person.name)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment