Skip to content

Commit 4975aa4

Browse files
committed
Change return value of Enumberable#each_cons
More compatibility to CRuby.
1 parent 666787b commit 4975aa4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mrbgems/mruby-enum-ext/mrblib/enum.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def each_cons(n, &block)
124124
ary << val.__svalue
125125
block.call(ary.dup) if ary.size == n
126126
end
127+
nil
127128
end
128129

129130
##

mrbgems/mruby-enum-ext/test/enum.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
assert("Enumerable#each_cons") do
2727
a = []
28-
(1..5).each_cons(3){|e| a << e}
28+
b = (1..5).each_cons(3){|e| a << e}
2929
assert_equal [[1, 2, 3], [2, 3, 4], [3, 4, 5]], a
30+
assert_equal nil, b
3031
end
3132

3233
assert("Enumerable#each_slice") do

0 commit comments

Comments
 (0)