The reversed()
method in Swift returns a view that presents the elements of a collection in the reverse order.
sequence.reversed()
This method does not take any parameters.
The value returned is a view showing the elements of the sequence sequence
in the reverse order.
// create some sequenceslet ages = [34, 23, 46, 26]let name = "Theodore"// get reverse viewprint(Array(ages.reversed()))print(String(name.reversed()))
reversed()
method on the sequences that we created. Then, we print the resulting view to the console.