Skip to content

Instantly share code, notes, and snippets.

@tkausch
Last active September 6, 2020 14:36
Show Gist options
  • Save tkausch/d3ffcaa8fadd3388305dcc3e33152dd5 to your computer and use it in GitHub Desktop.
Save tkausch/d3ffcaa8fadd3388305dcc3e33152dd5 to your computer and use it in GitHub Desktop.
Swift Problem Solving
extension String {
func reverse() -> String {
let result = self.reduce("") { (reversed, newChar) -> String in
return "\(newChar)" + reversed
}
return result
}
}
let palindrome = "MadamImAdam"
palindrome.reverse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment