summaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-28 23:31:32 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-28 23:31:32 (GMT)
commit797d2ab5d30beae91fb81ea04a896d9a8768469c (patch)
tree5ff5ef4a31d45235a548d73b293412f30f5be76b /range.c
parent54701725198c004dfab8756e915796285689cd9d (diff)
range.c: endless symbol range
* range.c (range_each): shortcirtuit endless symbol range too, as well as `#step`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r--range.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/range.c b/range.c
index 7f59a97..4f45b24 100644
--- a/range.c
+++ b/range.c
@@ -813,9 +813,14 @@ range_each(VALUE range)
rb_yield(LONG2FIX(i));
}
}
- else if (SYMBOL_P(beg) && SYMBOL_P(end)) { /* symbols are special */
+ else if (SYMBOL_P(beg) && (NIL_P(end) || SYMBOL_P(end))) { /* symbols are special */
beg = rb_sym2str(beg);
- rb_str_upto_each(beg, rb_sym2str(end), EXCL(range), sym_each_i, 0);
+ if (NIL_P(end)) {
+ rb_str_upto_endless_each(beg, sym_each_i, 0);
+ }
+ else {
+ rb_str_upto_each(beg, rb_sym2str(end), EXCL(range), sym_each_i, 0);
+ }
}
else {
VALUE tmp = rb_check_string_type(beg);