https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-05-21T15:19:42ZRuby Issue Tracking SystemRuby master - Bug #6473: Enumerable#counthttps://redmine.ruby-lang.org/issues/6473?journal_id=267352012-05-21T15:19:42Zno6v (Nobuhiro IMAI)nov@yo.rim.or.jp
<ul><li><strong>File</strong> <a href="/attachments/2704">enum_count.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/2704/enum_count.patch">enum_count.patch</a> added</li></ul><p>最終的に r25603 で size は呼ばなくなったようなので、コメントを修正したパッチを添付します。<br>
改行位置の関係で行数が多いですが、内容は1文目しか変更してません。</p> Ruby master - Bug #6473: Enumerable#counthttps://redmine.ruby-lang.org/issues/6473?journal_id=267362012-05-21T19:24:02Zmame (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>drbrain (Eric Hodel)</i></li></ul><p>Hello, drbrain</p>
<p>This is a doc issue of Enumerable#count.<br>
Could you check and import Nobuhiro's patch?</p>
<p>English translation:</p>
<p>The rdoc of Enumerable#count says:</p>
<p>Returns the number of items in <i>enum</i> if it responds to a #size call,<br>
otherwise the items are counted through enumeration. If an argument is</p>
<p>but actually it behaves as below:</p>
<p>class E<br>
include Enumerable</p>
<pre><code>def each
end
def size
1
end
</code></pre>
<p>end</p>
<p>e = E.new<br>
e.size # => 1<br>
e.count # => 0</p>
<p>As you see, it does not call #size. 1.8 series and 1.9.1 returns 1 instead of 0.</p>
<p>As r25603 seemed to finally decide to stop calling #size, I'm attaching a patch<br>
that changes the rdoc.<br>
The patch just changes the first line, though it looks bigger because of new line.</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p> Ruby master - Bug #6473: Enumerable#counthttps://redmine.ruby-lang.org/issues/6473?journal_id=268092012-05-25T08:51:57Zdrbrain (Eric Hodel)drbrain@segment7.net
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r35780.<br>
Nobuhiro, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>enum.c (enum_count): Enumerable#count no longer uses #size when<br>
counting elements. Patch by Nobuhiro IMAI. [ruby-trunk - Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Enumerable#count (Closed)" href="https://redmine.ruby-lang.org/issues/6473">#6473</a>]</li>
</ul>