Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/interlnk/interio.rb

Overview

InterIO - Sits on top of protocol and provides a ruby IO compatible I/O layer

Instance Method Summary collapse

Instance Method Details

#find_duplicatesObject



4
5
6
7
8
9
10
11
# File 'lib/interlnk/interio.rb', line 4

def find_duplicates
  # https://stackoverflow.com/questions/15284182/ruby-how-to-find-non-unique-elements-in-array-and-print-each-with-number-of-occ
  self.uniq.
    map { | e | [self.count(e), e] }.
    select { | c, _ | c > 1 }.
    sort.reverse.
    map { | c, e | e }
end