Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4dcd7cdacd
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (33 sloc) 0.586 kb
##
# Range
#
# ISO 15.2.14
class Range
##
# Calls the given block for each element of +self+
# and pass the respective element.
#
# ISO 15.2.14.4.4
def each(&block)
val = self.first
unless val.respond_to? :succ
raise TypeError, "can't iterate"
end
last = self.last
return self if (val <=> last) > 0
while((val <=> last) < 0)
block.call(val)
val = val.succ
end
block.call(val) unless exclude_end?
self
end
end
##
# Range is enumerable
#
# ISO 15.2.14.3
module Enumerable; end
class Range
include Enumerable
end
Jump to Line
Something went wrong with that request. Please try again.