Looking for swift Answers? Try Ask4KnowledgeBase
Looking for swift Keywords? Try Ask4Keywords

Swift Language Reversing Strings


Example

2.2
let aString = "This is a test string."

// first, reverse the String's characters 
let reversedCharacters = aString.characters.reverse()

// then convert back to a String with the String() initializer
let reversedString = String(reversedCharacters)

print(reversedString) // ".gnirts tset a si sihT"
3.0
let reversedCharacters = aString.characters.reversed()
let reversedString = String(reversedCharacters)