Skip to content

Instantly share code, notes, and snippets.

@JaNd3r
Last active August 2, 2016 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JaNd3r/1f04e998703b86e630278f9955e12980 to your computer and use it in GitHub Desktop.
Save JaNd3r/1f04e998703b86e630278f9955e12980 to your computer and use it in GitHub Desktop.
String extension which adds a function that returns the string with only its first character capitalized.
extension String {
func firstToUpper() -> String {
return self.isEmpty ? "" : String(self.characters.first!).uppercaseString + String(self.characters.dropFirst()).lowercaseString
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment