Method: Enumerable#detect_with_value
- Defined in:
- lib/jinx/helpers/enumerable.rb
#detect_with_value ⇒ (Object, Object)
Returns the first item and value for which an enumeration on the block given to this method returns a non-nil, non-false value.
116 117 118 119 120 121 122 |
# File 'lib/jinx/helpers/enumerable.rb', line 116 def detect_with_value value = nil match = detect do |*item| value = yield(*item) end [match, value] end |