Skip to content

Instantly share code, notes, and snippets.

@tkausch
Last active September 18, 2020 15:51
Show Gist options
  • Save tkausch/6e4b378fedd12edaf5d796e04c37fba2 to your computer and use it in GitHub Desktop.
Save tkausch/6e4b378fedd12edaf5d796e04c37fba2 to your computer and use it in GitHub Desktop.
How to capitalize the first letter of a string
extension String {
func capitalizingFirstLetter() -> String {
return prefix(1).capitalized + dropFirst()
}
mutating func capitalizeFirstLetter() {
self = self.capitalizingFirstLetter()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment