Skip to content

Instantly share code, notes, and snippets.

@certainty
Created July 18, 2012 11:06
Show Gist options
  • Save certainty/3135595 to your computer and use it in GitHub Desktop.
Save certainty/3135595 to your computer and use it in GitHub Desktop.
there you go
your_map = @users.inject({}) do |m,u|
duplicates = @users.select{ |u2| u.id != u2.id && u.email == u2.email }
(m[u.email] ||= []).concat(duplicates) unless duplicates.empty?
m
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment