[DOC] Tweaks for Array#count doc
This commit is contained in:
parent
e962c9c4c3
commit
bd19d3d163
Notes:
git
2024-08-24 15:50:16 +00:00
18
array.c
18
array.c
@ -6344,29 +6344,27 @@ rb_ary_compact(VALUE ary)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* array.count -> an_integer
|
* count -> integer
|
||||||
* array.count(obj) -> an_integer
|
* count(object) -> integer
|
||||||
* array.count {|element| ... } -> an_integer
|
* count {|element| ... } -> integer
|
||||||
*
|
*
|
||||||
* Returns a count of specified elements.
|
* Returns a count of specified elements.
|
||||||
*
|
*
|
||||||
* With no argument and no block, returns the count of all elements:
|
* With no argument and no block, returns the count of all elements:
|
||||||
*
|
*
|
||||||
* [0, 1, 2].count # => 3
|
* [0, :one, 'two', 3, 3.0].count # => 5
|
||||||
* [].count # => 0
|
|
||||||
*
|
*
|
||||||
* With argument +obj+, returns the count of elements <tt>==</tt> to +obj+:
|
* With argument +object+ given, returns the count of elements <tt>==</tt> to +object+:
|
||||||
*
|
*
|
||||||
* [0, 1, 2, 0.0].count(0) # => 2
|
* [0, :one, 'two', 3, 3.0].count(3) # => 2
|
||||||
* [0, 1, 2].count(3) # => 0
|
|
||||||
*
|
*
|
||||||
* With no argument and a block given, calls the block with each element;
|
* With no argument and a block given, calls the block with each element;
|
||||||
* returns the count of elements for which the block returns a truthy value:
|
* returns the count of elements for which the block returns a truthy value:
|
||||||
*
|
*
|
||||||
* [0, 1, 2, 3].count {|element| element > 1} # => 2
|
* [0, 1, 2, 3].count {|element| element > 1} # => 2
|
||||||
*
|
*
|
||||||
* With argument +obj+ and a block given, issues a warning, ignores the block,
|
* With argument +object+ and a block given, issues a warning, ignores the block,
|
||||||
* and returns the count of elements <tt>==</tt> to +obj+.
|
* and returns the count of elements <tt>==</tt> to +object+.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user