Michael Neumann wrote: > Hi, Moin! > %w(This is a list of words).group_by {|word| word.size} > > would result in: > > {5=>["words"], 1=>["a"], 2=>["is", "of"], 4=>["This", "list"]} > > Is this useful enough to include into Ruby? I have used this before when I needed to find files which have the same content. Basically I did this: (Yes, I used exactly the same name and almost the same logic as you. :)) module Enumerable def group_by result = Hash.new { |h, k| h[k] = Array.new } self.each do |item| group = yield(item) result[group] << item end return result end end And later: files.group_by { |file| hash_file(file) } So, yes, I think that this would make a great extension to the standard Ruby. > Regards, > Michael More regards, Florian Gross