Fix Enumerable#sole when element is a tuple#55808
Merged
byroot merged 1 commit intorails:mainfrom Sep 30, 2025
Merged
Conversation
byroot
reviewed
Sep 30, 2025
Member
|
I imagine this would now break |
ccbf576 to
aa0aad6
Compare
Member
Nope. |
byroot
reviewed
Sep 30, 2025
Comment on lines
+410
to
+422
| class KeywordYielder | ||
| include Enumerable | ||
|
|
||
| def each | ||
| yield 1, two: 3 | ||
| end | ||
| end | ||
|
|
||
| def test_sole_keyword_arguments | ||
| yielder = KeywordYielder.new | ||
| assert_equal [1, {two: 3}], yielder.sole | ||
| assert_equal yielder.first, yielder.sole | ||
| end |
Member
There was a problem hiding this comment.
I pushed an extra test to make sure *arguments do also collect keyword args.
aa0aad6 to
34cc80d
Compare
byroot
added a commit
that referenced
this pull request
Sep 30, 2025
Fix `Enumerable#sole` when element is a tuple
byroot
added a commit
that referenced
this pull request
Sep 30, 2025
Fix `Enumerable#sole` when element is a tuple
Member
|
Thanks for the fix, backported to 8-0-stable, and 7-2-stable. |
Contributor
Author
|
Thanks for the quick merge! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation / Background
This Pull Request has been created because #54341 introduced a behavior change for
Enumerable#solewhen the sole element is a tuple.Previously,
Enumerable#solewould return the full tuple (same asEnumerable#first). #54341 changed the behavior so thatEnumerable#soleonly returns the first element of the tuple.Fixes #55807.
Detail
This Pull Request changes
Enumerable#soleto return the full tuple, i.e. the same value asEnumerable#first.Additional information
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]