From: Brian Ross [mailto:p.brian.ross / gmail.com] 
# I'd imagine that this would return map as a new hash with the 
# keys modified. Is there anything like collect! for hashes?

the required pairings for hashes makes it fragile to implement a map/collect like feature similar to plain arrays.

you can create one if you like. just be careful.

eg, here is my simple-minded implementation,

irb(main):084:0> class Hash
irb(main):085:1> def map2
irb(main):086:2>   h={}
irb(main):087:2>   self.each do |k,v|
irb(main):088:3*      kk,vv=yield(k,v)
irb(main):089:3>      key = kk || k
irb(main):090:3>      val = vv || v
irb(main):091:3>      h[key] = val
irb(main):092:3>   end
irb(main):093:2>   h
irb(main):094:2> end
irb(main):095:1> end
=> nil
irb(main):096:0> hash.map2{|k,_| k.upcase}
=> {"NAME"=>"greg", "JOB"=>"boring", "HAIR"=>"plenty"}
irb(main):097:0> hash.map2{|k| k.upcase}
=> {"NAME"=>"greg", "JOB"=>"boring", "HAIR"=>"plenty"}
irb(main):098:0> hash.map2{|k,v| k.upcase}
=> {"NAME"=>"greg", "JOB"=>"boring", "HAIR"=>"plenty"}
irb(main):099:0> hash.map2{|k,v| [k.upcase,v.capitalize]}
=> {"NAME"=>"Greg", "JOB"=>"Boring", "HAIR"=>"Plenty"}


kind regards -botp