Project

General

Profile

Actions

Feature #17838

closed

`Set#intersect?` and enumerables

Added by marcandre (Marc-Andre Lafortune) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Target version:
-
[ruby-core:103635]

Description

Set#intersect? currently accepts only a set argument.

It should accept an enumerable argument:

[1, 2, 3].intersect?(Set[2, 3, 4]) # => true
Set[2, 3, 4].intersection([1, 2, 3]) # => Set[2, 3]
Set[2, 3, 4].intersect?([1, 2, 3]) # => ArgumentError

I expect set.intersect?(arg) to be an optimized version of !set.intersection(arg).empty?

Should I prepare a PR?

Updated by jeremyevans0 (Jeremy Evans) over 3 years ago

  • Tracker changed from Bug to Feature
  • Status changed from Open to Assigned
  • Backport deleted (2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN)

This makes sense to me. However, there is a explicit test currently that array arguments are not accepted. So this must be considered a feature request and not a bug. I've submitted an upstream pull request that implements this feature: https://github.com/ruby/set/pull/18

Actions #2

Updated by jeremyevans0 (Jeremy Evans) over 3 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0