From: Siep Korteling Date: 2008-09-09T05:41:34+09:00 Subject: Re: Is this a sensible implementation for Array#group_by ? Adam Shelly wrote: (...)> >> I'm just after some feedback really. I'm guessing i just couldn't find >> the good implementation of it :) > > It seems sensible to me, although I'd use a hash instead of a > associative array - it just looks cleaner. I didn't check the > performance difference though. > >> -Adam It's also in Ruby 1.8.7 Enumerable. Another possibility: use a set. require 'set' fruits = %w(apple banana pear plum nectarine orange melon).to_set p fruits.classify{|s| s.length} p fruits.classify{|s| s.include?("e")} regards, Siep -- Posted via http://www.ruby-forum.com/.