2010/12/12 "Martin J. Dst" <duerst / it.aoyama.ac.jp>: > > There are already such methods. At least group_by. Your proposal seems toe > a very special way to convert an enumerable to a hash. Enumerable#categorize is more general than Enumerable#group_by. Enumerable#group_by can specify only hash keys. It cannot specify hash values. > I think I get the idea of how this is supposed to work. But I'm not sure > what the actual use cases would be. Can you give some? I see. Assume a table as follows. ary = [ ["matz", "Yukihiro Matsumoto"], ["nobu", "Nobuyoshi Nakada"], ["akr", "Tanaka Akira"], ["usa", "Usaku NAKAMURA"], ["naruse", "NARUSE, Yui"], ["ko1", "SASADA Koichi"] ] Enumerable#categorize can be used to generate a hash from the right elements to left elements. (and left elements to right elements too.) pp ary.categorize {|e| [e[1], e[0]] } #=> {"Yukihiro Matsumoto"=>["matz"], "Nobuyoshi Nakada"=>["nobu"], "Tanaka Akira"=>["akr"], "Usaku NAKAMURA"=>["usa"], "NARUSE, Yui"=>["naruse"], "SASADA Koichi"=>["ko1"]} Since Enumerable#group_by cannot specify hash values, it cannot do it. > Who will be able to remember exactly what these options are,...? Most other > methods, in particular on Enumerables, don't have that many options. I think > that's for a good reason. I think option argument is adopted to ruby increasingly. -- Tanaka Akira