Last active
September 6, 2020 14:36
-
-
Save tkausch/d3ffcaa8fadd3388305dcc3e33152dd5 to your computer and use it in GitHub Desktop.
Swift Problem Solving
This file contains 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 { | |
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