Reverse a string

 Problem

I have a string and want to reverse it (with all of its characters in the reverse order).



 Recipe


// String literal
let s = "Hello World"

// Reverse its characters

let reversed = String(s.characters.reverse())
print(reversed)
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground