Commit d95c42ee authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2119 from ksss/range-each

Range#each fixnums are special
parents f882bc84 209bf256
......@@ -13,11 +13,23 @@ class Range
return to_enum :each unless block_given?
val = self.first
last = self.last
if val.kind_of?(Fixnum) && last.kind_of?(Fixnum) # fixnums are special
lim = last
lim += 1 unless exclude_end?
i = val
while i < lim
block.call(i)
i += 1
end
return self
end
unless val.respond_to? :succ
raise TypeError, "can't iterate"
end
last = self.last
return self if (val <=> last) > 0
while((val <=> last) < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment