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