How to reverse an array in Swift
In this tutorial, we are going to learn about how to reverse an array in Swift
Using the reverse() method
We can reverse an array in Swift by using the built-in `reverse() method.
Here is an example, that reverses the following array:
var arr = ["a", "b", "c"]
arr.reverse()
print(arr)
Output:
["c", "b", "a"]
Similarly, you can also reverse the array in swift like this:
var arr = ["a", "b", "c"]
var reversedArr : [String] = []
for el in arr.reversed(){
reversedArr.append(el)
}
print(reversedArr)