Method: Hash#collate
- Defined in:
- lib/nano/hash/collate.rb
#collate ⇒ Object
Returns a new hash built by iterating through each key,value pair and updating the new hash.
– Note that this method may get some fine tuning as it currently expects the block to return a “mini-hash” pair – parhaps a 2-element array woud be better? ++
13 14 15 16 17 |
# File 'lib/nano/hash/collate.rb', line 13 def collate # :yield: newhash = {} each_pair{ |k,v| newhash.update( yield(k,v) ) } newhash end |