Last active
March 4, 2016 21:33
-
-
Save Jesse-calkin/b00c50a514d7a40fc7bd to your computer and use it in GitHub Desktop.
String extension adding a reverse function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
func reverse() -> String { | |
guard self.characters.count > 1 else { return self } | |
var reversed = "" | |
for char in self.characters.reverse() { | |
reversed += "\(char)" | |
} | |
return reversed | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment