-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add downcase option to String#camelcase #7717
Conversation
Just |
src/string.cr
Outdated
@@ -3503,10 +3503,10 @@ class String | |||
# "eiffel_tower".camelcase # => "EiffelTower" | |||
# "isolated_integer".camelcase(Unicode::CaseOptions::Turkic) # => "İsolatedİnteger" | |||
# ``` | |||
def camelcase(options : Unicode::CaseOptions = Unicode::CaseOptions::None) | |||
def camelcase(options : Unicode::CaseOptions = Unicode::CaseOptions::None, lowercase_first_letter = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def camelcase(options : Unicode::CaseOptions = Unicode::CaseOptions::None, lowercase_first_letter = false) | |
def camelcase(options : Unicode::CaseOptions = Unicode::CaseOptions::None, *, lowercase_first_letter = false) |
to prevent just false
as argument, suggested in #7709 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd stand for just lower
as the argument name. It's clearly understandable that lower
in context of camelcase
means exactly lower camelcase
, which is a common term. No need for a long and explicit name here.
I'd suggest one of the following (in order of preference):
|
@straight-shoota @ysbaddaden what do you think about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with this, but I'd prefer to name the argument more explicitly downcase_first
.
That’s bad. |
Or |
No. It should only be usable as a named argument to clearly express the semantics. |
Co-Authored-By: wontruefree <[email protected]>
@straight-shoota CI seems to be failing due to running too long. Is this common for CI and how can I rerun it? |
@straight-shoota thank you for re-running this. |
That's disturbing. |
@vladfaust Which part is disturbing? |
I'm late to the party, but where the hell did downcase came from? Downcase camelcase doesn't mean anything, it's just confusing. This is lower or upper camelcase (which affects the first letter) not downcase —a completely different method and meaning 😕 |
@ysbaddaden It downcases the first character, the equivalent method is |
Hm, actually, it doesn't even downcase the first character when it's uppercase: |
I think the API is fine, the above is just a bug in this PR's implementation. |
Isn't this method generally behaving incorrectly? This method returns |
@r00ster91 Pascal case was discussed in the related issue, please do not duplicate the discussion in this PR. |
resolves #7709