https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112015-07-30T01:39:59ZRuby Issue Tracking SystemRuby master - Bug #11406: Inconsistent behavior when creating a range of strings which end in an integer greater than 10https://redmine.ruby-lang.org/issues/11406?journal_id=536052015-07-30T01:39:59Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/53605/diff?detail_id=38549">diff</a>)</li></ul><p>It's not inconsistent, but derived from the behavior of <code>String#succ</code>.</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="nb">p</span> <span class="s2">"foo9"</span><span class="p">.</span><span class="nf">succ</span> <span class="c1">#=> "fop0"</span>
</code></pre>
<p>And it ended with "zzzz9", or exceeds the length of "foo10".</p>
<p>I agree that the current behavior is less convenient in such cases.</p> Ruby master - Bug #11406: Inconsistent behavior when creating a range of strings which end in an integer greater than 10https://redmine.ruby-lang.org/issues/11406?journal_id=536992015-08-09T03:36:16Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p><a href="https://github.com/nobu/ruby/tree/bug/11406-String%23upto-numeric-suffix" class="external">https://github.com/nobu/ruby/tree/bug/11406-String%23upto-numeric-suffix</a></p> Ruby master - Bug #11406: Inconsistent behavior when creating a range of strings which end in an integer greater than 10https://redmine.ruby-lang.org/issues/11406?journal_id=537032015-08-09T06:52:11ZHanmac (Hans Mackowiak)hanmac@gmx.de
<ul></ul><p>i think that might break some things ... (it might break some applications)</p>
<p>like with "1.2.9".succ, i dont know if that still work</p> Ruby master - Bug #11406: Inconsistent behavior when creating a range of strings which end in an integer greater than 10https://redmine.ruby-lang.org/issues/11406?journal_id=537042015-08-09T08:09:19Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Hans Mackowiak wrote:</p>
<blockquote>
<p>i think that might break some things ... (it might break some applications)</p>
<p>like with "1.2.9".succ, i dont know if that still work</p>
</blockquote>
<p><code>String#succ</code> isn't changed at all with my patch, but only <code>String#upto</code> when the receiver and the limit share common prefix and numerical suffixes.</p>
<p>The case affected is that alphabetical part is followed by the numerical suffix.<br>
E.g.,</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="s2">"1a2b9"</span><span class="p">.</span><span class="nf">upto</span><span class="p">(</span><span class="s2">"1a2b10"</span><span class="p">).</span><span class="nf">to_a</span>
</code></pre>
<p>returns an empty array now, but <code>["1a2b9", "1a2b10"]</code> with this patch.</p>
<p>In other words, your example has been handled specially already.</p> Ruby master - Bug #11406: Inconsistent behavior when creating a range of strings which end in an integer greater than 10https://redmine.ruby-lang.org/issues/11406?journal_id=799112019-07-23T18:32:37Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul>