enum.find(ifnone = nil) { |obj| block } â obj or nilenum.find(ifnone = nil) â an_enumerator
Instance Public methods
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).find { |i| i % 5 == 0 and