Skip to content

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

Merged
1 commit merged intomainfrom
test_593820135
Dec 26, 2023
Merged

In Ruby repeated fields, each_index actually iterates over the index (#11767)#15190
1 commit merged intomainfrom
test_593820135

Conversation

@copybara-service
Copy link
Copy Markdown

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