D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Enumerable
/
Filename :
detect-i.ri
back
Copy
U:RDoc::AnyMethod[iI"detect:ETI"Enumerable#detect;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"JReturns the first element for which the block returns a truthy value.;To:RDoc::Markup::BlankLine o; ; [I"UWith a block given, calls the block with successive elements of the collection; ;TI"Jreturns the first element for which the block returns a truthy value:;T@o:RDoc::Markup::Verbatim; [I"?(0..9).find {|element| element > 2} # => 3 ;T:@format0o; ; [I"TIf no such element is found, calls +if_none_proc+ and returns its return value.;T@o;; [I"C(0..9).find(proc {false}) {|element| element > 12} # => false ;TI"b{foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1] ;TI"[{foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => [] ;T; 0o; ; [I"0With no block given, returns an Enumerator.;T: @fileI"enum.c;T:0@omit_headings_from_table_of_contents_below000[ I"(*args);T@!FI"Enumerable;TcRDoc::NormalModule0[@$FI" find;T