Commit 4975aa4c authored by Kenji Okimoto's avatar Kenji Okimoto

Change return value of Enumberable#each_cons

More compatibility to CRuby.
parent 666787be
...@@ -124,6 +124,7 @@ module Enumerable ...@@ -124,6 +124,7 @@ module Enumerable
ary << val.__svalue ary << val.__svalue
block.call(ary.dup) if ary.size == n block.call(ary.dup) if ary.size == n
end end
nil
end end
## ##
......
...@@ -25,8 +25,9 @@ end ...@@ -25,8 +25,9 @@ end
assert("Enumerable#each_cons") do assert("Enumerable#each_cons") do
a = [] 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 [[1, 2, 3], [2, 3, 4], [3, 4, 5]], a
assert_equal nil, b
end end
assert("Enumerable#each_slice") do assert("Enumerable#each_slice") 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