Skip to content
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

Confusing Regex::MatchData#size naming #4565

Closed
makenowjust opened this issue Jun 14, 2017 · 2 comments
Closed

Confusing Regex::MatchData#size naming #4565

makenowjust opened this issue Jun 14, 2017 · 2 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Milestone

Comments

@makenowjust
Copy link
Contributor

Regex::MatchData#size returns the number of capture group, in other words m.size (m is Regex::MatchData instance) is difference from m.to_a.size always (m.size + 1 == m.to_a.size). size is very very popular method name on Crystal and Regex::MatchData looks like Array, so it makes me confusing.

I think group_size is better name for this method, and size should return same value of m.to_a.size. How do you think?

NOTE: Ruby's MatchData#size returns same value of m.to_a.size.

@straight-shoota
Copy link
Member

Yes, it should be that m[m.size - 1] is the last element in the match data.

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Jun 14, 2017
@asterite
Copy link
Member

@makenowjust I agree with you

makenowjust added a commit to makenowjust/crystal that referenced this issue Jun 14, 2017
makenowjust added a commit to makenowjust/crystal that referenced this issue Jun 14, 2017
@asterite asterite added this to the Next milestone Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

No branches or pull requests

3 participants