Sha256: 90734273c527a1f6c090db3cd6795ff44a3f19d25ed789bd116184210987eeee

Contents?: true

Size: 238 Bytes

Versions: 6

Compression:

Stored size: 238 Bytes

Contents

class Array
  # Like <tt>Array#detect</tt>, but returns the calculated value
  def grab(&blk)
    result = each do |element|
      value = yield element
      break value if value
    end
    return if result == self
    result
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
leap-0.5.5 lib/leap/core_ext.rb
leap-0.5.4 lib/leap/core_ext.rb
leap-0.5.3 lib/leap/core_ext.rb
leap-0.5.2 lib/leap/core_ext.rb
leap-0.5.1 lib/leap/core_ext.rb
leap-0.5.0 lib/leap/core_ext.rb