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

In Ruby repeated fields, each_index actually iterates over the index (#11767) #15190

Merged
1 commit merged into from
Dec 26, 2023

Conversation

copybara-service[bot]
Copy link

In Ruby repeated fields, each_index actually iterates over the index (#11767)

Currently we're aliasing each_index to each_with_index, incorrectly passing both the index and the value of a repeated field to the block.

What we want is to just pass the index. Luckily this is a method on Ruby arrays, so we just wrap the native Ruby array method.

Fixes #7806

Closes #11767

COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c
FUTURE_COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c

…11767)

Currently we're aliasing `each_index` to `each_with_index`, incorrectly passing both the index and the value of a repeated field to the block.

What we want is to just pass the index. Luckily this is a method on Ruby arrays, so we just wrap the native Ruby array method.

Fixes #7806

Closes #11767

COPYBARA_INTEGRATE_REVIEW=#11767 from shaldengeki:shaldengeki-repeated-field-each-index-returns-actual-index 874916c
PiperOrigin-RevId: 593835025
@copybara-service copybara-service bot closed this pull request by merging all changes into main in f869cfa Dec 26, 2023
@copybara-service copybara-service bot deleted the test_593820135 branch December 26, 2023 20:14
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.

ruby: repeated_field aliases each_index to each_with_index - thus incorrectly returning the each not the index
1 participant