Loops
for(int i = 0; i < 10; i++)
printf("i=%d\n", i);for i in 0..<10 {
print(i)
}var shoppingList = ["catfish", "water", "tulips"]
for item in shoppingList {
print(item)
}Last updated
for(int i = 0; i < 10; i++)
printf("i=%d\n", i);for i in 0..<10 {
print(i)
}var shoppingList = ["catfish", "water", "tulips"]
for item in shoppingList {
print(item)
}Last updated
for (index, item) in shoppingList.enumerated() {
print("The item at index \(index) is \(item)")
}for item in shoppingList where item.starts(with: "c") {
print(item)
}while shoppingList.count > 0 {
print(shoppingList.remove(at: 0))
}repeat {
print(shoppingList.remove(at: 0))
} while shoppingList.count > 0