Sha256: bdeb381afd8a1a43663542b2bef17c272de2f0841c3226aea9047d7207d26466

Contents?: true

Size: 370 Bytes

Versions: 18

Compression:

Stored size: 370 Bytes

Contents

require 'more_core_extensions/core_ext/array/element_counts'

module MoreCoreExtensions
  module ArrayDuplicates
    #
    # Returns an Array of the duplicates found.
    #
    #   [1, 2, 3, 4, 2, 4].duplicates  #=> [2, 4]
    def duplicates
      element_counts.select { |_k, v| v > 1 }.keys
    end
  end
end

Array.send(:include, MoreCoreExtensions::ArrayDuplicates)

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
more_core_extensions-4.5.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-4.4.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-4.3.1 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-4.3.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-4.2.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-4.1.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-4.0.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.8.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.7.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.6.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.5.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.4.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.3.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.2.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.1.1 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.1.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-3.0.0 lib/more_core_extensions/core_ext/array/duplicates.rb
more_core_extensions-2.0.0 lib/more_core_extensions/core_ext/array/duplicates.rb