-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String.toPascalCase #429
Comments
Hi Alberto! There are also some implementation details to work out like handling Would you like to try implementing this and submitting a PR? |
That's fair. The name can be changed... So to account for null and empty string are we saying it should return option or result type? |
Hi Alberto, I checked the other implementations and think we should go with not specifying the culture aka using the one that is set up globally (done by As for the For the empty string I would go with empty string to mimick other methods/functions like Consider something along the lines of: open System
[<RequireQualifiedAccess>]
module String =
let capitalize (s: string) =
match s with
| "" -> ""
| s ->
let chars = s.ToCharArray() //initially want to go with Array.ofSeq s, but it turned out to be slooooow
chars.[0] <- Char.ToUpper(chars.[0])
String chars It does fewer string allocations than your implementation and should (I didn't check it) be quicker than the one you provided (it would be nice to microbenchmark this in order to make an informed decision about the implementation). EDIT: I just "checked" it with Quick "testing" results for this approach:
|
Could you provide a PR for that? I can do the review, help with testing, perf, or anything you don't feel comfortable with. |
Initial performance "check":
|
Description
Feature request
The text was updated successfully, but these errors were encountered: