let names = ["a", "b", "c"]
for name in names {
print(name)
}
guard let currentUser = currentUser,
let photos = currentUser.photos as? [ModelAttachment] else
{
// break or return
}
// now 'photos' is available outside the guard
for object in photos {
let url = object.url
}
for object in array {
// object is replaced with the array item for each loop
}
// access items of an array
let languages = ["Swift", "Java", "Go", "JavaScript"]
for language in languages {
print(language)
}
// an array of fruits
let fruits = ["Apple", "Peach", "Mango"]
// for loop to iterate over array
for fruit in fruits {
print(fruit)
}