Calls the given block for each element of self and pass the
respective element.
ISO 15.2.14.4.4
# File mrblib/range.rb, line 12
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
if not exclude_end? and (val <=> last) == 0
block.call(val)
end
self
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.