Sha256: d8895bb0b283c9f960b92af3eb92cae4e3893d369907223747af304348fa3ba4

Contents?: true

Size: 387 Bytes

Versions: 17

Compression:

Stored size: 387 Bytes

Contents

require 'backports/1.9.1/enumerable/each_with_object' unless Enumerable.method_defined? :each_with_object

unless Enumerable.method_defined? :filter_map
  module Enumerable
    def filter_map
      return to_enum(:filter_map) unless block_given?

      each_with_object([]) do |item, res|
        processed = yield(item)
        res << processed if processed
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
backports-3.25.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.24.1 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.24.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.23.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.22.1 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.22.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.21.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.20.2 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.20.1 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.20.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.19.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.18.2 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.18.1 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.18.0 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.17.2 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.17.1 lib/backports/2.7.0/enumerable/filter_map.rb
backports-3.17.0 lib/backports/2.7.0/enumerable/filter_map.rb