Last active
September 18, 2020 15:51
-
-
Save tkausch/6e4b378fedd12edaf5d796e04c37fba2 to your computer and use it in GitHub Desktop.
How to capitalize the first letter of a 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 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