-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Fix Enumerable#each_cons and each_slice to return a receiver #1509
Fix Enumerable#each_cons and each_slice to return a receiver #1509
Conversation
What should I make CI successful for? |
Make a branch with version guards and send a pull request to https://github.com/ruby/spec. |
Note that the Travis was revived by 9d4266f , only managing non-x86 cases. |
enum.c
Outdated
* a # => [[1, 2, 3], [2, 3, 4], [3, 4, 5]] | ||
* | ||
* a = [] | ||
* h = {foo: 0, bar: 1, baz: 2, bam: 3} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* h = {foo: 0, bar: 1, baz: 2, bam: 3} | |
* h = {foo: 0, bar: 1, baz: 2, bam: 3} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm the original author of these methods and this is fine with me.
This PR fixes the following build error. ```console % bundle exec rspec ./spec/rubocop/cop/layout/block_alignment_spec.rb:222 (snip) # ./lib/rubocop/cop/layout/block_alignment.rb:97:in `start_for_block_node' # ./lib/rubocop/cop/layout/block_alignment.rb:82:in `on_block' # ./lib/rubocop/cop/commissioner.rb:100:in `public_send' # ./lib/rubocop/cop/commissioner.rb:100:in `block (2 levels) in trigger_responding_cops' # ./lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling' # ./lib/rubocop/cop/commissioner.rb:99:in `block in trigger_responding_cops' ``` https://app.circleci.com/pipelines/github/rubocop/rubocop/5414/workflows/4a7e4b81-7380-41e5-8ede-e28d9160010d/jobs/201236 I reported on this change of behavior. https://bugs.ruby-lang.org/issues/18268 And it was due to the following change. ruby/ruby#1509 This PR will be changed to the cop logic that is not affected by the above Ruby 3.1.0-dev change.
Why not?
I think
Enumerable#each_cons
andEnumerable#each_slice
are extensions ofeach
method, so to return a receiver looks a natural behavior.