Skip to content

Instantly share code, notes, and snippets.

@clarkeben
Last active November 17, 2023 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkeben/feabc7a34dda7cef6ac00cfcebc73665 to your computer and use it in GitHub Desktop.
Save clarkeben/feabc7a34dda7cef6ac00cfcebc73665 to your computer and use it in GitHub Desktop.
iterate-array
let names = ["Bob", "Alice", "Mallory"]
for (index, name) in names.enumerated() {
print("Index \(index): \(name)")
}
let fruits = ["Mango", "Orange", "Apple", "Pear"]
for fruit in fruits {
print(fruit)
}
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