Issue #16039 has been updated by JustJosh (Joshua Stowers).


# *#cover?*
I do not think we should use the name `cover?` because the types of arguments accepted by `Range#cover?` would be incompatible with this use case.

For example:
```ruby
(1..3).cover?(2) # true
```
But if Array's implementation worked similarly, we would have the following issue:
```ruby
[1, 2, 3].cover?(2) # true by design of Range#cover?
[1, 2, 3].cover?([2]) # true because all values in argument are also in self
[1, [2], 3].cover?([2]) # ?
```

# *#superset?*
It is worth noting that the unique nature of sets would affect the expected behavior of this method:
```ruby
[1, 2, 3].contains?([1, 2, 2]) # false because self contains only one 2
[1, 2, 3].superset?([1, 2, 2]) # true because duplicates are ignored 
```
In my opinion, the unambiguous behavior of `superset?` is preferable.

# *Array*/*Set*

Although I personally like `array.superset?()` more than `array.to_set.superset?()`, I think `Set` would benefit from more compatibility with `Enumerable`. So I agree with @Dan0042.

I recommend that we update `Set#superset?`, `proper_superset?`, `subset?`, and `proper_subset?` to accept any `Enumerable`.


----------------------------------------
Feature #16039: Array#contains? to check if one array contains another array
https://bugs.ruby-lang.org/issues/16039#change-83230

* Author: cha1tanya (Prathamesh Sonpatki)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I woud like to propose `Array#contains?` which will check if the one array is part of another array.
Implementation can be as follows:

```
def contains?(other)
  (other - self).empty?
end
```

Some test cases:

```
[1, 2, 3].contains?([2, 3]) => true
[1, 2, 3].contains?([]) => true
[1, 2, 3].contains?([1, 2, 3, 4]) => false
[].contains?([]) => true
[].contains?([1, 2, 3, 4]) => false
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>