Skip to content

Commit 2fba299

Browse files
committed
[GR-40333] Enumerable#each_cons and each_slice to return a receiver
PullRequest: truffleruby/3641
2 parents 34e127f + 4167bbb commit 2fba299

File tree

4 files changed

+3
-4
lines changed

4 files changed

+3
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Compatibility:
7373
* Raise `EncodingError` at parse time when Hash literal contains a Symbol key with invalid encoding (#2848, @andrykonchin).
7474
* Fix `Array` methods `reject`, `reject!`, `inject`, `map`, `select`, `each_index` and handle a case when array is modified by a passed block like CRuby does (#2822, @andrykonchin, @eregon).
7575
* Fix `Array` methods `select!` and `keep_if` and handle a case when exception is raised in a passed block properly (@andrykonchin).
76+
* Fix `Enumerable` methods `each_cons` and `each_slice` to return receiver (#2733, @horakivo)
7677

7778
Performance:
7879

spec/tags/core/enumerable/each_cons_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/tags/core/enumerable/each_slice_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/ruby/truffleruby/core/enumerable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def each_cons(num)
660660
array.shift if array.size > n
661661
yield array.dup if array.size == n
662662
end
663-
nil
663+
self
664664
end
665665

666666
def each_slice(slice_size)
@@ -685,7 +685,7 @@ def each_slice(slice_size)
685685
end
686686

687687
yield a unless a.empty?
688-
nil
688+
self
689689
end
690690

691691
def find(ifnone=nil)

0 commit comments

Comments
 (0)