Issue #14473 has been updated by duerst (Martin Drst).


As long as we only consider ranges starting and ending with integers, concepts such as subset and superset make sense. But ranges can also be constructed from other numbers, and other objects in general.

What e.g. should be the result of `(5..10).subset?(5.5..7.9)`?

Or what if we introduce something like `Range.new(1, 10, step: 2)`, which would produce `[1, 3, 5, 7, 9]` when converted to an `Array`?

----------------------------------------
Feature #14473: Add Range#subrange?
https://bugs.ruby-lang.org/issues/14473#change-70607

* Author: greggzst (Grzegorz Jakubiak)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Hi there,

I'd like to propose a method that returns true when a range that the method gets called on is a subrange of a range passed in as an argument.

Example:

~~~ ruby
(2..4).subrange?(1...4) 
=> true
(-2..2).subrange?(-1..3) 
=> false
~~~




---Files--------------------------------
0001-range.c-add-subset-superset-methods.patch (8.84 KB)


-- 
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>