ruby-changes:51090
From: nobu <ko1@a...>
Date: Sun, 29 Apr 2018 08:31:37 +0900 (JST)
Subject: [ruby-changes:51090] nobu:r63297 (trunk): range.c: endless symbol range
nobu 2018-04-29 08:31:32 +0900 (Sun, 29 Apr 2018) New Revision: 63297 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63297 Log: range.c: endless symbol range * range.c (range_each): shortcirtuit endless symbol range too, as well as `#step`. Modified files: trunk/range.c Index: range.c =================================================================== --- range.c (revision 63296) +++ range.c (revision 63297) @@ -813,9 +813,14 @@ range_each(VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L813 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/