Skip to content

Instantly share code, notes, and snippets.

@jjhageman
Created September 20, 2017 23:27
Show Gist options
  • Save jjhageman/1769a610b9888a9843fa8f5e4c8ef518 to your computer and use it in GitHub Desktop.
Save jjhageman/1769a610b9888a9843fa8f5e4c8ef518 to your computer and use it in GitHub Desktop.
Swift 3 snake_case to camelCase
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