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

Improve documentation of Array#[Range] #10243

Merged

Conversation

straight-shoota
Copy link
Member

Resolves #10222

This is only a draft for now, please review the wording for improvements.
I'll then copy appropriate documentation to String#[Range].

@HertzDevil
Copy link
Contributor

There are also Slice#[](Range) and BitArray#[](Range), by the way.

src/array.cr Outdated Show resolved Hide resolved
src/array.cr Show resolved Hide resolved
src/array.cr Show resolved Hide resolved
src/array.cr Outdated Show resolved Hide resolved
Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
@straight-shoota
Copy link
Member Author

BitArray is a bit different, so that should be covered separately to get this merged.

src/array.cr Outdated Show resolved Hide resolved
src/array.cr Outdated Show resolved Hide resolved
@straight-shoota
Copy link
Member Author

@HertzDevil Looks like I had that already fixed but failed to push the changes. 🙈

src/array.cr Outdated Show resolved Hide resolved
src/string.cr Outdated
self[*Indexable.range_to_index_and_count(range, size) || raise IndexError.new]
end

# Like `#[Range]`, but returns `nil` if the range's start is out of bounds.
# Like `#[Range]`, but returns `nil` if `range.begin` is out of range.
Copy link
Member

Choose a reason for hiding this comment

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

This #[Range] syntax is really confusing and it is not recognized by the doc generator.

#[](Range) would be recognized, though.
Same for #[](Int, Int).

I realize this is pre-existing, but on the other hand, this PR is about improving documentation.

@straight-shoota straight-shoota added this to the 1.1.0 milestone Jun 1, 2021
@straight-shoota straight-shoota merged commit 881eb81 into crystal-lang:master Jun 4, 2021
@straight-shoota straight-shoota deleted the docs/index-accessor-range branch June 4, 2021 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document Array#[] (range : Range) behavior with negative indices
4 participants