Skip to content

[DOC] Tweaks for String#count #13839

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

Merged
merged 2 commits into from
Jul 12, 2025
Merged

Conversation

BurdetteLamar
Copy link
Member

I'd like to get rid of file doc/character_selectors.rdoc. I think it's better for the methods' documentation to handle things on their own (as I've shown here).

Right now, it's also referred to at:

  • #delete/delete!.
  • #squeeze/#squeeze!.

When these are all 'tweaked', those references will be gone and we can delete the file.

@BurdetteLamar BurdetteLamar added the Documentation Improvements to documentation. label Jul 9, 2025
s.count('abc', 'def') # => 0
s.count('') # => 0

Selectors may include negations, ranges, and escapes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "escapes"? Like "\n"? That's a feature of the string rather than String#count.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what "escapes" is supposed to mean. It's mentioned in the previous documentation, though. What do you thinki?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the original documentation, it means escaping the special characters like ^ and -

"1^2^3".count("\\^1") # => 3
"^-^".count("\\^\\-") # => 3

@BurdetteLamar
Copy link
Member Author

@peterzhu2118, on second thought, maybe it's better to retain file doc/character_selectors.rdoc. I was mistaken in thinking how few methods use it (there are four more than I realized).

Maybe review that file for possible improvements, and add/revise the examples in its nine referring methods?

If agreed, I'll close this PR.

@peterzhu2118
Copy link
Member

It's your call, but I think there's only 3 other places that use it (String#tr, String#delete, String#squeeze).

@BurdetteLamar
Copy link
Member Author

I'm rethinking this.

@BurdetteLamar
Copy link
Member Author

Re-rethinking this. And marking as draft.

@BurdetteLamar BurdetteLamar reopened this Jul 11, 2025
@BurdetteLamar BurdetteLamar marked this pull request as draft July 11, 2025 21:24
@BurdetteLamar BurdetteLamar marked this pull request as ready for review July 11, 2025 22:47
@peterzhu2118 peterzhu2118 merged commit b0db93c into ruby:master Jul 12, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Improvements to documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants