Sha256: b9ab867ab8b6d2d3b654e47b773178326f2850b58335694653e66ca9c250bad1

Contents?: true

Size: 198 Bytes

Versions: 20

Compression:

Stored size: 198 Bytes

Contents

module Enumerable

  def collect_if(&b)
    a = map(&b)
    # to get the same semantics as select{|e| e}
    a.delete(false)
    a.compact!
    a
  end

  alias_method :map_if, :collect_if
  
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
facets-1.3.0 lib/facets/core/enumerable/collect_if.rb
facets-1.3.1 lib/facets/core/enumerable/collect_if.rb
facets-1.3.2 lib/facets/core/enumerable/collect_if.rb
facets-1.3.3 lib/facets/core/enumerable/collect_if.rb
facets-1.4.0 lib/facets/core/enumerable/collect_if.rb
facets-1.4.1 lib/facets/core/enumerable/collect_if.rb
facets-1.4.2 lib/facets/core/enumerable/collect_if.rb
facets-1.4.3 lib/facets/core/enumerable/collect_if.rb
facets-1.4.4 lib/facets/core/enumerable/collect_if.rb
facets-1.4.5 lib/facets/core/enumerable/collect_if.rb
facets-1.7.0 lib/facets/core/enumerable/collect_if.rb
facets-1.7.30 lib/facets/core/enumerable/collect_if.rb
facets-1.7.38 lib/facets/core/enumerable/collect_if.rb
facets-1.7.46 lib/facets/core/enumerable/collect_if.rb
facets-1.8.0 lib/facets/core/enumerable/collect_if.rb
facets-1.8.20 lib/facets/core/enumerable/collect_if.rb
facets-1.8.49 lib/facets/core/enumerable/collect_if.rb
facets-1.8.51 lib/facets/core/enumerable/collect_if.rb
facets-1.8.54 lib/facets/core/enumerable/collect_if.rb
facets-1.8.8 lib/facets/core/enumerable/collect_if.rb