Skip to content

Commit

Permalink
Change return value of Enumerable#each_slice
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 cff54ab
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 @@ -154,6 +154,7 @@ def each_slice(n, &block)
end
end
block.call(ary) unless ary.empty?
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 @@ -31,8 +31,9 @@

assert("Enumerable#each_slice") do
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 nil, b
end

assert("Enumerable#group_by") do
Expand Down

0 comments on commit cff54ab

Please sign in to comment.