Last active
November 17, 2023 23:44
-
-
Save clarkeben/feabc7a34dda7cef6ac00cfcebc73665 to your computer and use it in GitHub Desktop.
iterate-array
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 names = ["Bob", "Alice", "Mallory"] | |
for (index, name) in names.enumerated() { | |
print("Index \(index): \(name)") | |
} |
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 fruits = ["Mango", "Orange", "Apple", "Pear"] | |
for fruit in fruits { | |
print(fruit) | |
} |
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 cars = ["BMW", "Aldi", "Toyota", "Ford"] | |
var counter = 0 | |
while counter < cars.count { | |
print(cars[counter]) | |
counter += 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment