Issue #6669 has been updated by mame (Yusuke Endoh).

Status changed from Assigned to Feedback

Yutaka Hara,

We discussed your slide at the developer meeting (7/21).

Matz was positive to the feature itself, but there was no
method name that matz liked.  Please find another good name.


Here is a discussion summary:

* hash_map, map_hash
Matz's most favorite, but not enough to accept.

* associate
Not bad, but not enough to accept.

* mash
Such a created word is not good.

* apply, convert, process, graph
Bad.  They suggest something different.

* morph (Yugui suggested)
This might be a correct terminology (?), but it is difficult
for those unfamiliar with category theory.

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Feature #6669: A method like Hash#map but returns hash
https://bugs.ruby-lang.org/issues/6669#change-28394

Author: yhara (Yutaka HARA)
Status: Feedback
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 2.0.0


=begin
Given a hash h, h.map returns an array(alist), but sometimes I hope it returned a hash.

Example:

  class Hash
    def apply(&block)
      self.inject({}) do |h, (k, v)|
        new_k, new_v = *block.call(k, v)
        h[new_k] = new_v
        h
      end
    end
  end
  
  score = {
    taro: [1,3,2], 
    jiro: [3,5,8,4], 
    saburo: [2,9]
  }
  max_score = score.apply{|k,v| [k, v.max]}
  #=> {taro: 3, jiro: 8, saburo: 9}
  p max_score[:taro]
  #=> 3

I'm not thinking "apply" is a perfect name for this. Maybe "hash_map" is better
(we already have "flat_map").
=end



-- 
http://bugs.ruby-lang.org/