Sha256: a1a580c65e5efe791de2d32d5432e0b18be0417639fc50accd90382d488fe76d

Contents?: true

Size: 299 Bytes

Versions: 10

Compression:

Stored size: 299 Bytes

Contents

class Hash

  # Inverse of #delete_if.
  #
  #   h = { :a => 1, :b => 2, :c => 3 }
  #   r = h.delete_unless{|k,v| v == 1}
  #   r  #=> { :a => 1 }
  #   h  #=> { :a => 1 }
  #
  # CREDIT: Daniel Schierbeck

  def delete_unless #:yield:
    delete_if{ |key, value| ! yield(key, value) }
  end

end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/hash/delete_unless.rb
facets-3.1.0 lib/core/facets/hash/delete_unless.rb
facets-3.0.0 lib/core/facets/hash/delete_unless.rb
facets-2.9.3 lib/core/facets/hash/delete_unless.rb
facets-2.9.2 src/core/facets/hash/delete_unless.rb
facets-2.9.2 lib/core/facets/hash/delete_unless.rb
facets-2.9.1 lib/core/facets/hash/delete_unless.rb
facets-2.9.0 lib/core/facets/hash/delete_unless.rb
facets-2.9.0.pre.2 lib/core/facets/hash/delete_unless.rb
facets-2.9.0.pre.1 lib/core/facets/hash/delete_unless.rb