Support object does'n have < method

This commit is contained in:
ksss
2016-11-24 10:34:14 +09:00
parent f5a86ca530
commit 9e2faec8e4
+2 -3
View File
@@ -58,9 +58,8 @@ module Enumerable
def take(n)
raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int)
raise ArgumentError, "attempt to take negative size" if n < 0
n = n.to_int
i = n.to_int
raise ArgumentError, "attempt to take negative size" if i < 0
ary = []
self.each do |*val|
break if ary.size >= n