diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 23:31:32 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 23:31:32 +0000 |
commit | 797d2ab5d30beae91fb81ea04a896d9a8768469c (patch) | |
tree | 5ff5ef4a31d45235a548d73b293412f30f5be76b /range.c | |
parent | 54701725198c004dfab8756e915796285689cd9d (diff) | |
download | ruby-797d2ab5d30beae91fb81ea04a896d9a8768469c.tar.gz |
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.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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); |