Last active
August 29, 2015 14:04
-
-
Save ridget/31df0669666adcf6091e to your computer and use it in GitHub Desktop.
group by and map on values in group thanks @mattc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# works in ruby 1.9 | |
count.group_by { |o| o.site.name }.inject({}) { |m, (k,v)| m[k] = v.map(&:user_id); m } | |
# works in ruby 2.0 and above | |
count.group_by { |o| o.site.name }.map{ |k,v| [k, v.map(&:user_id)]}.to_h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment