Created
February 21, 2011 12:44
-
-
Save iNecas/837012 to your computer and use it in GitHub Desktop.
finding duplicities in array in one line
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
comps = ["PC", "MAC", "PC", "PC", "LINUX", "MAC", "DIDAKTIK"] | |
duplicities = comps.group_by{|x| x.first}.find_all{|k,v| v.size > 1}.map{|x| x.first} | |
duplicities # => ["MAC","PC"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment