Created
June 27, 2015 19:35
-
-
Save tLewisII/b817ce113b87eb523027 to your computer and use it in GitHub Desktop.
Test if a string has all the same characters.
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 isHomogeneous:Bool { | |
| let charSet = Set(self.characters) | |
| return charSet.count == 0 || charSet.count == 1 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment