Merge pull request #3576 from okkez/fix-return-value-of-each-cons

Change return value of Enumberable#each_cons
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-04-03 18:04:33 +09:00
committed by GitHub
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -124,6 +124,7 @@ module Enumerable
ary << val.__svalue
block.call(ary.dup) if ary.size == n
end
nil
end
##
+2 -1
View File
@@ -25,8 +25,9 @@ end
assert("Enumerable#each_cons") do
a = []
(1..5).each_cons(3){|e| a << e}
b = (1..5).each_cons(3){|e| a << e}
assert_equal [[1, 2, 3], [2, 3, 4], [3, 4, 5]], a
assert_equal nil, b
end
assert("Enumerable#each_slice") do