Created
June 12, 2016 08:54
-
-
Save cansurmeli/8111156bd4c0890de9b37a1d9d014ab7 to your computer and use it in GitHub Desktop.
Convert camelCase to titleCase with Swift via functional programming
This file contains hidden or 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
let camelCaseString = "noRealTimeLocationData" | |
let stringCharacters = String(camelCaseString).characters.map{ String($0) } | |
let titleCaseString = stringCharacters.flatMap{ $0.lowercaseString != $0 ? " " + $0 : $0 }.joinWithSeparator("") | |
print(titleCaseString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
me tinkering with functional programming
probably will be more expressive in the future...