Instance Method

reverse()

Reverses the elements of the collection in place.

Declaration

mutating func reverse()

Discussion

The following example reverses the elements of an array of characters:

var characters: [Character] = ["C", "a", "f", "é"]
characters.reverse()
print(characters)
// Prints "["é", "f", "a", "C"]

Complexity: O(n), where n is the number of elements in the collection.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software