https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112013-03-27T11:00:52ZRuby Issue Tracking SystemRuby master - Feature #8172: IndexError-returning counterparts to destructive Array methodshttps://redmine.ruby-lang.org/issues/8172?journal_id=379552013-03-27T11:00:52Zsawa (Tsuyoshi Sawada)
<ul></ul><p>=begin<br>
In the above, I missed to say that there is no counterpart for (({Array#[]=})). There should be one for it as well, but I cannot think of a good method name.<br>
=end</p> Ruby master - Feature #8172: IndexError-returning counterparts to destructive Array methodshttps://redmine.ruby-lang.org/issues/8172?journal_id=379572013-03-27T11:24:23Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>=begin<br>
(({Hash})) has (({#store})) as an alias of (({#[]=})).<br>
=end</p> Ruby master - Feature #8172: IndexError-returning counterparts to destructive Array methodshttps://redmine.ruby-lang.org/issues/8172?journal_id=379592013-03-27T11:53:17Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p>This may be just an issue of wording: You say "index is out of range".<br>
By definition, Ruby arrays don't have a range. They can grow<br>
dynamically. In many cases, this is a big feature.</p>
<p>Also, you complain about inserting nil. So what about the following case:</p>
<p>a = [1, 2, 3]; a[3] = :foo; a # => [1, 2, 3, :foo]</p>
<p>There is no nil, so maybe this is okay. But the array is expanded.<br>
Should there be an error?</p>
<p>Regards, Martin.</p>
<p>On 2013/03/27 10:51, sawa (Tsuyoshi Sawada) wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-2 status-7 priority-4 priority-default closed" title="Feature: IndexError-returning counterparts to destructive Array methods (Feedback)" href="https://redmine.ruby-lang.org/issues/8172">#8172</a> has been reported by sawa (Tsuyoshi Sawada).</p>
<hr>
<p>Feature <a class="issue tracker-2 status-7 priority-4 priority-default closed" title="Feature: IndexError-returning counterparts to destructive Array methods (Feedback)" href="https://redmine.ruby-lang.org/issues/8172">#8172</a>: IndexError-returning counterparts to destructive Array methods<br>
<a href="https://bugs.ruby-lang.org/issues/8172" class="external">https://bugs.ruby-lang.org/issues/8172</a></p>
</blockquote> Ruby master - Feature #8172: IndexError-returning counterparts to destructive Array methodshttps://redmine.ruby-lang.org/issues/8172?journal_id=379602013-03-27T11:55:42Zsawa (Tsuyoshi Sawada)
<ul></ul><p>=begin</p>
<blockquote>
<p>Martin<br>
For clarification, I meant to have it return an error only in cases where (({nil})) needs to be inserted otherwise. So cases like the following should not return an error:</p>
</blockquote>
<pre><code>a = [1, 2, 3]; a[3] = :foo; a # => (actually it should be a different method name) [1, 2, 3, :foo]
[1, 2, 3].insert!(3, :foo) # => [1, 2, 3, :foo]
[1, 2, 3].fill!(:foo, 3) # => [1, 2, 3, :foo]
</code></pre>
<p>=end</p> Ruby master - Feature #8172: IndexError-returning counterparts to destructive Array methodshttps://redmine.ruby-lang.org/issues/8172?journal_id=379612013-03-27T12:26:25Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>I am not against the idea itself, but using bang (!) for the names is not consistent with other bang methods.</p>
<p>Matz.</p> Ruby master - Feature #8172: IndexError-returning counterparts to destructive Array methodshttps://redmine.ruby-lang.org/issues/8172?journal_id=835672019-12-30T19:19:30Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/83567/diff?detail_id=56026">diff</a>)</li></ul>