D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
count-i.ri
back
Copy
U:RDoc::AnyMethod[iI" count:ETI"Enumerable#count;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"VReturns the count of elements, based on an argument or block criterion, if given.;To:RDoc::Markup::BlankLine o; ; [I"IWith no argument and no block given, returns the number of elements:;T@o:RDoc::Markup::Verbatim; [I"+[0, 1, 2].count # => 3 ;TI"+{foo: 0, bar: 1, baz: 2}.count # => 3 ;T:@format0o; ; [I"#With argument +object+ given, ;TI"Ereturns the number of elements that are <tt>==</tt> to +object+:;T@o;; [I",[0, 1, 2, 1].count(1) # => 2 ;T; 0o; ; [I";With a block given, calls the block with each element ;TI"Sand returns the number of elements for which the block returns a truthy value:;T@o;; [I"D[0, 1, 2, 3].count {|element| element < 2} # => 2 ;TI"C{foo: 0, bar: 1, baz: 2}.count {|key, value| value < 2} # => 2;T; 0: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below0I"Qcount -> integer count(object) -> integer count {|element| ... } -> integer ;T0[ I" (p1);T@%FI"Enumerable;TcRDoc::NormalModule00