Project

General

Profile

Bug #6473 ยป enum_count.patch

no6v (Nobuhiro IMAI), 05/21/2012 03:19 PM

View differences:

enum.c
* enum.count(item) -> int
* enum.count { |obj| block } -> int
*
* Returns the number of items in <i>enum</i> if it responds to a #size call,
* otherwise the items are counted through enumeration. If an argument is
* given the number of items in <i>enum</i> that are equal to <i>item</i> are
* counted. If a block is given, it counts the number of elements yielding a
* true value.
* Returns the number of items in <i>enum</i> through enumeration.
* If an argument is given the number of items in <i>enum</i> that
* are equal to <i>item</i> are counted. If a block is given, it
* counts the number of elements yielding a true value.
*
* ary = [1, 2, 4, 2]
* ary.count #=> 4
    (1-1/1)