Skip to content

Commit

Permalink
Change return value of Enumberable#each_cons
Browse files Browse the repository at this point in the history
More compatibility to CRuby.
  • Loading branch information
okkez committed Apr 3, 2017
1 parent 666787b commit 4975aa4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions mrbgems/mruby-enum-ext/mrblib/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def each_cons(n, &block)
ary << val.__svalue
block.call(ary.dup) if ary.size == n
end
nil
end

##
Expand Down
3 changes: 2 additions & 1 deletion mrbgems/mruby-enum-ext/test/enum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@

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
Expand Down

0 comments on commit 4975aa4

Please sign in to comment.