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

Start index parameter's name in subrange-accepting methods #11348

Closed
HertzDevil opened this issue Oct 23, 2021 · 0 comments · Fixed by #11350
Closed

Start index parameter's name in subrange-accepting methods #11348

HertzDevil opened this issue Oct 23, 2021 · 0 comments · Fixed by #11350

Comments

@HertzDevil
Copy link
Contributor

HertzDevil commented Oct 23, 2021

There are three different ways to name the start index parameter in a method that accepts a subrange:

  • start, e.g. Array#[](start : Int, count : Int), String#byte_slice(start : Int, count : Int)
  • from, e.g. Array#fill(value : T, from : Int, count : Int)
  • index, e.g. Array#[]=(index : Int, count : Int, value : T), String#delete_at(index : Int, count : Int)

Across those methods, these parameters always have the same meaning and, with the exception of #fill and Slice#[], the same semantics too, so IMO they should share the same name. This would also mean one less thing to remember in case named arguments are used.

My preference is start; it captures the meaning most accurately, and is already the most frequently used name among them. from is often paired with to but the latter is absent in these overloads (if it did appear, surely from..to ought to take care of such an overload), whereas index does not indicate where the subrange is actually picked.

For comparison, all the related overloads that accept a Range seem to consistently use range as the parameter name already.

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

Successfully merging a pull request may close this issue.

1 participant