Working with arrays in swift?
Example:
var fruits = ["Apple", "Banana", "Cherry"]
print(fruits[0])
Arrays are ordered collections of values. The example defines an array of fruits and prints the first element.
Solution:
fruits.append("Dragonfruit")
fruits.remove(at: 1)
for fruit in fruits {
print(fruit)
}
In the solution, we demonstrate how to add an element, remove an element, and loop through the array.