Sha256: 57ffdc0656604aec0e211b260de3feabb94b9578bb846631442c0489585a5ab9
Contents?: true
Size: 686 Bytes
Versions: 4
Compression:
Stored size: 686 Bytes
Contents
class Hash # Iterates through each pair and updates a the hash # in place. This is formally equivalent to #collate! # But does not use #collate to accomplish the task. # Hence #update_each is probably a bit faster. # # require 'facet/hash/update_each' # # # example to do # #-- # Note that this may get some fine tuning as currently # it expects the block to return a "mini-hash" pair. #++ def update_each # :yield: dup.each_pair{ |k,v| update( yield(k,v) ); } self end # Same as #update_each, but deletes the key element first. def replace_each # :yield: dup.each_pair{ |k,v| delete( k ); update( yield(k,v) ); } self end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facets-0.6.3 | lib/facet/hash/update_each.rb |
facets-0.7.0 | lib/facet/hash/update_each.rb |
facets-0.7.1 | lib/facet/hash/update_each.rb |
facets-0.7.2 | lib/facet/hash/update_each.rb |