Sha256: 773dafa2d99fbb5316c7998d3f6ec677f06ca37e755ce3e6a4be87abda61c633

Contents?: true

Size: 325 Bytes

Versions: 6

Compression:

Stored size: 325 Bytes

Contents

unless Array.method_defined? :intersect?
  require 'backports/tools/arguments'

  class Array
    def intersect?(array)
      array = Backports.coerce_to_ary(array)

      if size < array.size
        smaller = self
      else
        smaller, array = array, self
      end
      (array & smaller).size > 0
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
backports-3.25.0 lib/backports/3.1.0/array/intersect.rb
backports-3.24.1 lib/backports/3.1.0/array/intersect.rb
backports-3.24.0 lib/backports/3.1.0/array/intersect.rb
backports-3.23.0 lib/backports/3.1.0/array/intersect.rb
backports-3.22.1 lib/backports/3.1.0/array/intersect.rb
backports-3.22.0 lib/backports/3.1.0/array/intersect.rb