-
-
Save dennisvennink/afeb1bbb7d7554516f97db956c6974a0 to your computer and use it in GitHub Desktop.
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
let xs = [1, 2, 3, 4, 5] | |
for (element, index) in zip(xs, xs.indices) { | |
if index == xs.startIndex { | |
print("START") | |
} | |
print(element) | |
if index == xs.index(before: xs.endIndex) { | |
print("END") | |
} | |
} | |
// Prints: "START\n1\n2\n3\n4\n5\nEND\n" |
Thank you, I missed that one.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 10 should read
index == xs.index(before: xs.endIndex)