Sha256: 0c46751959199c636cfa76ee6961aa1af7d7983700431acf896abf06c1311a0d
Contents?: true
Size: 404 Bytes
Versions: 112
Compression:
Stored size: 404 Bytes
Contents
class Array def ids map(&:id) end def dups? find { |e| rindex(e) != index(e) } ? true : false end def dups (select { |e| rindex(e) != index(e) }).uniq end def dups_with_index return {} unless self.dups? hash = Hash.new { |h, k| h[k] = [] } each_with_index do |val, idx| hash[val] << idx end hash.delete_if { |_k, v| v.size == 1 } hash end end
Version data entries
112 entries across 112 versions & 1 rubygems