Skip to content

Instantly share code, notes, and snippets.

@cansurmeli
Created June 12, 2016 08:54
Show Gist options
  • Save cansurmeli/8111156bd4c0890de9b37a1d9d014ab7 to your computer and use it in GitHub Desktop.
Save cansurmeli/8111156bd4c0890de9b37a1d9d014ab7 to your computer and use it in GitHub Desktop.
Convert camelCase to titleCase with Swift via functional programming
let camelCaseString = "noRealTimeLocationData"
let stringCharacters = String(camelCaseString).characters.map{ String($0) }
let titleCaseString = stringCharacters.flatMap{ $0.lowercaseString != $0 ? " " + $0 : $0 }.joinWithSeparator("")
print(titleCaseString)
@cansurmeli
Copy link
Author

me tinkering with functional programming

probably will be more expressive in the future...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment