Skip to content

Instantly share code, notes, and snippets.

@ojiry
Created March 16, 2012 05:11
Show Gist options
  • Save ojiry/2048584 to your computer and use it in GitHub Desktop.
Save ojiry/2048584 to your computer and use it in GitHub Desktop.
a = [1, 2, 3, 4, 5, 6, 5, 4]
a.uniq.select{|i| a.index(i) != a.rindex(i)} #=> [4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment