Skip to content

Instantly share code, notes, and snippets.

@norsez
Last active February 28, 2019 09:38
Show Gist options
  • Save norsez/b6fcf59164d5a6c52bd96dd8238ae9f6 to your computer and use it in GitHub Desktop.
Save norsez/b6fcf59164d5a6c52bd96dd8238ae9f6 to your computer and use it in GitHub Desktop.
isPalindrome in Swift 4.2
extension String {
var isPalindrome: Bool {
let reversed = String( self.reversed() )
for index in self.indices {
if self.lowercased()[index] != reversed.lowercased()[index] {
return false
}
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment