Sha256: 8fa3a69a160e709a1279a86654c04a18eeb7781d4abced379f6a81f21340f58d

Contents?: true

Size: 227 Bytes

Versions: 10

Compression:

Stored size: 227 Bytes

Contents

class Array

  # Inverse of #delete_if.
  #
  #   [1,2,3].delete_unless{ |x| x < 2 }
  #   => [1,2]
  #
  # CREDIT: Daniel Schierbeck

  def delete_unless(&block)
    delete_if { |element| not block.call(element) }
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/array/delete_unless.rb
facets-2.8.3 lib/core/facets/array/delete_unless.rb
facets-2.8.2 lib/core/facets/array/delete_unless.rb
facets-2.8.1 lib/core/facets/array/delete_unless.rb
facets-2.8.0 lib/core/facets/array/delete_unless.rb
facets-2.7.0 lib/core/facets/array/delete_unless.rb
facets-2.6.0 lib/core/facets/array/delete_unless.rb
facets-2.5.1 lib/core/facets/array/delete_unless.rb
facets-2.5.0 lib/core/facets/array/delete_unless.rb
facets-2.5.2 lib/core/facets/array/delete_unless.rb