On Oct 8, 9:00 ¨Βν¬ Πετε ΘοδησοΌπθοδη®®®ΐμωςισ®γονΎ χςοτεΊ > Hi folks, > > Given: > > Person = Struct.new(:name,:age,:city) > people_array = [ > Person.new('bob',12,'SFO'), > Person.new('dave',14,'NYC'), > Person.new('jane',6,'LDN') ] > > people_map = {} > people_array.each{ |p| people_map[p.name] = p } > > Is there a cleaner way to build people_map? I'm thinking there might be > something like: > > people_map = people_array.to_map{ |x| x.name } > > in the standard library somewhere that I don't know of. Facets has #graph / #mash. require 'facets' people_array.graph{ |p| [p.name, p] } # or people_array.mash{ |p| [p.name, p] } T.