method
find
find(p1 = v1)
public
Passes each entry in enum to block. Returns the first for which block is not false. If no object matches, calls ifnone and returns its result when it is specified, or returns nil otherwise.
If no block is given, an enumerator is returned instead.
(1..10).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> nil (1..100).detect {|i| i % 5 == 0 and i % 7 == 0 } #=> 35
Register or
log in
to add new notes.
tadman -
April 1, 2009
MattStopa -
March 11, 2012
1 thank
Returns the element, not block result
Enumerable#find will always return the element that is found, not the result of the block provided.
0 thanks


