Created
January 13, 2017 11:51
-
-
Save mlvea/f51e495f26a8986de90b1bc87ec4320f to your computer and use it in GitHub Desktop.
Abbreviation from CamelCase String
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 abbrevatedByCapitalLetters() -> String { | |
var abbrevations = [Character]() | |
for character in self.characters where String(character) == String(character).uppercased() { | |
abbrevations.append(character) | |
} | |
return String(abbrevations) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment