Skip to content

Instantly share code, notes, and snippets.

@daveed
Created July 9, 2010 04:11
Show Gist options
  • Save daveed/469026 to your computer and use it in GitHub Desktop.
Save daveed/469026 to your computer and use it in GitHub Desktop.
module Enumerable
def dups
inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys
end
end
# arr = [2,8,8,42,7,33,42]
# puts arr.dups.inspect
# [8, 42]
@daveed
Copy link
Author

daveed commented Jul 9, 2010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment