Skip to content

Commit

Permalink
Enumerable#each_{cons,slice} to return enumerators
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Sep 26, 2015
1 parent 524a038 commit 0aa83c5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mrbgems/mruby-enum-ext/mrblib/enum.rb
Expand Up @@ -116,6 +116,7 @@ def each_cons(n, &block)
raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
raise ArgumentError, "invalid size" if n <= 0

return to_enum(:each_cons,n) unless block
ary = []
n = n.to_int
self.each do |*val|
Expand Down Expand Up @@ -143,6 +144,7 @@ def each_slice(n, &block)
raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
raise ArgumentError, "invalid slice size" if n <= 0

return to_enum(:each_slice,n) unless block
ary = []
n = n.to_int
self.each do |*val|
Expand Down

0 comments on commit 0aa83c5

Please sign in to comment.