Skip to content

Instantly share code, notes, and snippets.

@tLewisII
Created June 27, 2015 19:35
Show Gist options
  • Select an option

  • Save tLewisII/b817ce113b87eb523027 to your computer and use it in GitHub Desktop.

Select an option

Save tLewisII/b817ce113b87eb523027 to your computer and use it in GitHub Desktop.
Test if a string has all the same 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