Last active
February 28, 2019 09:38
-
-
Save norsez/b6fcf59164d5a6c52bd96dd8238ae9f6 to your computer and use it in GitHub Desktop.
isPalindrome in Swift 4.2
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 { | |
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