summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'range.c')
-rw-r--r--range.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/range.c b/range.c
index 3b56ee7..2faf2f3 100644
--- a/range.c
+++ b/range.c
@@ -306,7 +306,16 @@ range_each(range)
rb_raise(rb_eTypeError, "cannot iterate from %s",
rb_class2name(CLASS_OF(beg)));
}
- if (TYPE(beg) == T_STRING) {
+ if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
+ long lim = FIX2LONG(end);
+ long i;
+
+ if (!EXCL(range)) lim += 1;
+ for (i=FIX2LONG(beg); i<lim; i++) {
+ rb_yield(LONG2NUM(i));
+ }
+ }
+ else if (TYPE(beg) == T_STRING) {
VALUE args[5];
long iter[2];