Sha256: 82135c3887fab275fa193026e31ff867205b9385d83397f9b4e27b461bce0241

Contents?: true

Size: 332 Bytes

Versions: 7

Compression:

Stored size: 332 Bytes

Contents

class Array

  unless method_defined?(:select!)

    # As with #select but modifies the Array in place.
    #
    #   a = [1,2,3,4,5,6,7,8,9,10]
    #   a.select!{ |e| e % 2 == 0 }
    #   a  #=> [2,4,6,8,10]
    #
    # CREDIT: Gavin Sinclair
    #
    def select!  # :yield:
      reject!{ |e| not yield(e) }
    end

  end

end

Version data entries

7 entries across 6 versions & 1 rubygems

Version Path
facets-2.9.3 lib/core/facets/array/select.rb
facets-2.9.2 lib/core/facets/array/select.rb
facets-2.9.2 src/core/facets/array/select.rb
facets-2.9.1 lib/core/facets/array/select.rb
facets-2.9.0 lib/core/facets/array/select.rb
facets-2.9.0.pre.2 lib/core/facets/array/select.rb
facets-2.9.0.pre.1 lib/core/facets/array/select.rb