Sha256: 3d7fae8d0f5d6c96f0aef7d0049622f334ff1212f178b70acbde7f0c5012c272

Contents?: true

Size: 326 Bytes

Versions: 9

Compression:

Stored size: 326 Bytes

Contents

module Enumerable
  def map_select(value_for_skip = nil)
    self.inject([]) do |acc, item|
      (value = yield(item)) == value_for_skip ? acc : acc << value
    end
  end
  
  def map_detect(value_for_no_matching = nil)
    self.each { |el| if result = yield(el) then return result end }
    value_for_no_matching
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
justools-1.3.0 lib/justools/core_ext/enumerable.rb
justools-1.2.4 lib/justools/core_ext/enumerable.rb
justools-1.2.3 lib/justools/core_ext/enumerable.rb
justools-1.2.2 lib/justools/core_ext/enumerable.rb
justools-1.2.1 lib/justools/core_ext/enumerable.rb
justools-1.2.0 lib/justools/core_ext/enumerable.rb
core_utilities-0.1.3 lib/core_utilities/core_ext/enumerable.rb
core_utilities-0.1.1 lib/core_utilities/core_ext/enumerable.rb
core_utilities-0.1.0 lib/core_utilities/core_ext/enumerable.rb