Sha256: 8a1a9dbe76c5e17d88f155e19383c5001d5fffa008c7f8860bfa6a380dfa7434

Contents?: true

Size: 223 Bytes

Versions: 18

Compression:

Stored size: 223 Bytes

Contents

class Array
  # like detect, 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

18 entries across 18 versions & 1 rubygems

Version Path
leap-0.4.6 lib/leap/core_ext.rb
leap-0.4.5 lib/leap/core_ext.rb
leap-0.4.4 lib/leap/core_ext.rb
leap-0.4.3 lib/leap/core_ext.rb
leap-0.4.2 lib/leap/core_ext.rb
leap-0.4.1 lib/leap/core_ext.rb
leap-0.4.0 lib/leap/core_ext.rb
leap-0.3.3 lib/leap/core_ext.rb
leap-0.3.2 lib/leap/core_ext.rb
leap-0.3.1 lib/leap/core_ext.rb
leap-0.3.0 lib/leap/core_ext.rb
leap-0.2.6 lib/leap/core_ext.rb
leap-0.2.5 lib/leap/core_ext.rb
leap-0.2.4 lib/leap/core_ext.rb
leap-0.2.3 lib/leap/core_ext.rb
leap-0.2.2 lib/leap/core_ext.rb
leap-0.2.1 lib/leap/core_ext.rb
leap-0.2.0 lib/leap/core_ext.rb