From: Pete Hodgson Date: 2008-10-09T16:10:22+09:00 Subject: Re: Filling a hash from an enumerable Pe�a, Botp wrote: > From: Pe�a, Botp [mailto:botp@delmonte-phil.com] > # >> people_array.map{ |p| p.name } > # => ["bob", "dave", "jane"] > > pls ignore above, i'm still searching my lost brain :) > > try #group_by, > > >> people_array.group_by{ |p| p.name } >> > => {"bob"=>[#], "dave"=>[#], "jane"=>[#]} > Thanks, but that's not quite what I wanted. It creates a hash whose values are lonely arrays, rather than a map whose values are the structs themselves. I guess I'll just have to monkey-patch Enumerable with a to_map method. Should probably figure out a better name first tho.