Created
September 20, 2017 23:27
-
-
Save jjhageman/1769a610b9888a9843fa8f5e4c8ef518 to your computer and use it in GitHub Desktop.
Swift 3 snake_case to camelCase
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 { | |
var camelCased: String { | |
let items = self.components(separatedBy: "_") | |
return items[1...].reduce(items[0].lowercased(), { $0 + $1.capitalized }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment