Permalink
Browse files

Shouldn't call `each` method if size is 0

  • Loading branch information...
ksss committed Nov 24, 2016
1 parent 9e2faec commit 5134734541dd993f74a40b1621009add2cf110bf
Showing with 3 additions and 1 deletion.
  1. +3 −1 mrbgems/mruby-enum-ext/mrblib/enum.rb
@@ -61,9 +61,11 @@ def take(n)
i = n.to_int
raise ArgumentError, "attempt to take negative size" if i < 0
ary = []
return ary if i == 0
self.each do |*val|
break if ary.size >= n
ary << val.__svalue
i -= 1
break if i == 0
end
ary
end

0 comments on commit 5134734

Please sign in to comment.