The reverse()
method is used to reverse a sequence in Swift.
sequence.reverse()
This method returns the sequence, but with its elements reversed.
// create sequences var arr1 = [3, 45, 12, 1] var arr2 = ["a", "b", "c", "d"] // reverse arrays arr1.reverse() arr2.reverse() // print results print(arr1) print(arr2)
In the code above:
arr1
and arr2
.reverse()
method.RELATED TAGS
CONTRIBUTOR
View all Courses