Revisions

gist: 111514 Download_button fork
public
Public Clone URL: git://gist.github.com/111514.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Array
  
  def antiuniq
    
    duplicates = []
    clone = [] + self
    
    while clone.length > 0
      item = clone.pop
      duplicates.push(item) if clone.include?(item) || duplicates.include?(item)
    end
  
    return duplicates
  end
  
  def antiuniq!
    self.replace antiuniq
  end
  
end