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:
parent
5470172519
commit
797d2ab5d3
1 changed files with 7 additions and 2 deletions
9
range.c
9
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue