Skip to content

Instantly share code, notes, and snippets.

@jqr
Created February 20, 2009 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqr/67787 to your computer and use it in GitHub Desktop.
Save jqr/67787 to your computer and use it in GitHub Desktop.
module Enumerable
def group_by_individual
grouped = {}
each do |item|
yield(item).each do |key|
grouped[key] ||= []
grouped[key] << item
end
end
grouped
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment