From: Gary Wright Date: 2007-03-30T10:27:02+09:00 Subject: Re: code too hashy, I think On Mar 29, 2007, at 8:58 PM, James Edward Gray II wrote: > # or group the data by size > by_size = all_stuff.inject(Hash.new { |size, a| size[a] = [] }) do | > grouped, s| > grouped[s.size_code] << s > grouped > end > pp by_size Set has a nice method, classify, that can help with this if you aren't concerned with duplicates. require 'set' by_size = all_stuff.to_set.classify { |s| s.size_code } I'm surprised classify isn't part of Enumerable. It is a generalization of Enumerable#partition. Gary Wright