Skip to content

Instantly share code, notes, and snippets.

@testzugang
Last active December 16, 2015 02:59
Show Gist options
  • Save testzugang/5366598 to your computer and use it in GitHub Desktop.
Save testzugang/5366598 to your computer and use it in GitHub Desktop.
If in need for the opposite of "uniq" get only the duplicated entries in an array.
duplicate_keys = []
all_keys.uniq.each do |k|
count = all_keys.count(k)
duplicate_keys << k if count > 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment