Commit 6a992a25 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3577 from okkez/fix-return-value-of-each-slice

Change return value of Enumerable#each_slice
parents fea8d00e cff54ab2
...@@ -155,6 +155,7 @@ module Enumerable ...@@ -155,6 +155,7 @@ module Enumerable
end end
end end
block.call(ary) unless ary.empty? block.call(ary) unless ary.empty?
nil
end end
## ##
......
...@@ -32,8 +32,9 @@ end ...@@ -32,8 +32,9 @@ end
assert("Enumerable#each_slice") do assert("Enumerable#each_slice") do
a = [] a = []
(1..10).each_slice(3){|e| a << e} b = (1..10).each_slice(3){|e| a << e}
assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], a assert_equal [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], a
assert_equal nil, b
end end
assert("Enumerable#group_by") do assert("Enumerable#group_by") do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment