Shouldn't call each method if size is 0

This commit is contained in:
ksss
2016-11-24 10:35:15 +09:00
parent 9e2faec8e4
commit 5134734541
+3 -1
View File
@@ -61,9 +61,11 @@ module Enumerable
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