1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2018-04-28 23:31:32 +00:00
parent 5470172519
commit 797d2ab5d3

View file

@ -813,9 +813,14 @@ range_each(VALUE range)
rb_yield(LONG2FIX(i)); 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); 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 { else {
VALUE tmp = rb_check_string_type(beg); VALUE tmp = rb_check_string_type(beg);