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

Correctly calculate size for array enumerator #515

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

bdewater
Copy link
Contributor

I don't think this is an actual problem for anybody, but if we're passing a size to to_enum it should be correct. Example:

array = ["a", "b", "c"]
drop = 1

current = array.each_with_index.drop(drop).to_enum { enumerable.size } 
current.size # 3 - wrong!
current.to_a.size # 2

new = array.each_with_index.drop(drop).to_enum { enumerable.size - drop } 
new.size # 2

Example:
array = ["a", "b", "c"]
drop = 1

current = array.each_with_index.drop(drop).to_enum { enumerable.size }
current.size # 3
current.to_a.size # 2

new = array.each_with_index.drop(drop).to_enum { enumerable.size - drop }
new.size # 2
Copy link
Contributor

@Mangara Mangara left a comment

Choose a reason for hiding this comment

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

Good catch!

@Mangara
Copy link
Contributor

Mangara commented Oct 28, 2024

Could you write a quick unreleased changelog entry for this? I like keeping the change log up-to-date, instead of having to go through everything that merged when cutting a release.

@Mangara Mangara merged commit 7390536 into Shopify:main Dec 9, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants