https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2012-05-21T20:59:48Z
Ruby Issue Tracking System
Ruby master - Feature #6445: request for default length/position on string index
https://redmine.ruby-lang.org/issues/6445?journal_id=26743
2012-05-21T20:59:48Z
mame (Yusuke Endoh)
mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li></ul><p>Hello,</p>
<p>I created a patch that add a syntactic sugar from (arg..) to (arg..-1).</p>
<p>ary = [1, 2, 3, 4]<br>
p ary[2..] #=> [3, 4]</p>
<p>Matz, what do you think?</p>
<p>diff --git a/parse.y b/parse.y<br>
index 9f9093b..d272492 100644<br>
--- a/parse.y<br>
+++ b/parse.y<br>
@@ -2168,6 +2168,18 @@ arg : lhs '=' arg<br>
$$ = dispatch2(dot3, $1, $3);<br>
%*/<br>
}</p>
<ul>
<li>
<pre><code> | arg tDOT2
</code></pre>
</li>
<li>
<pre><code> {
</code></pre>
</li>
<li>
<pre><code> /*%%%*/
</code></pre>
</li>
<li>
<pre><code> value_expr($1);
</code></pre>
</li>
<li>
<pre><code> $$ = NEW_DOT2($1, NEW_LIT(INT2FIX(-1)));
</code></pre>
</li>
<li>
<pre><code> if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit)) {
</code></pre>
</li>
<li>
<pre><code> deferred_nodes = list_append(deferred_nodes, $$);
</code></pre>
</li>
<li>
<pre><code> }
</code></pre>
</li>
<li>
<pre><code> /*%
</code></pre>
</li>
<li>
<pre><code> $$ = dispatch2(dot2, $1, INT2FIX(-1));
</code></pre>
</li>
<li>
<pre><code> %*/
</code></pre>
</li>
<li>
<pre><code> }
| arg '+' arg
{
/*%%%*/
</code></pre>
</li>
</ul>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p>
Ruby master - Feature #6445: request for default length/position on string index
https://redmine.ruby-lang.org/issues/6445?journal_id=26946
2012-06-01T11:58:45Z
knu (Akinori MUSHA)
knu@ruby-lang.org
<ul></ul><p>It would look nice and work fine with indexing strings and arrays, but if it were put in you would've come to want (1..).each {|i| .. } to work as well.</p>
<p>It might be better to default the omitted end to +Infinity and then make {Array,String,..}#[] understand +Infinity as an index, I guess?</p>
Ruby master - Feature #6445: request for default length/position on string index
https://redmine.ruby-lang.org/issues/6445?journal_id=31525
2012-10-25T18:43:34Z
yhara (Yutaka HARA)
<ul><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>3.0</i></li></ul>
Ruby master - Feature #6445: request for default length/position on string index
https://redmine.ruby-lang.org/issues/6445?journal_id=31527
2012-10-25T18:56:20Z
yhara (Yutaka HARA)
<ul><li><strong>Target version</strong> changed from <i>3.0</i> to <i>2.6</i></li></ul>
Ruby master - Feature #6445: request for default length/position on string index
https://redmine.ruby-lang.org/issues/6445?journal_id=68783
2017-12-25T18:15:05Z
naruse (Yui NARUSE)
naruse@airemix.jp
<ul><li><strong>Target version</strong> deleted (<del><i>2.6</i></del>)</li></ul>