From: owen@... Date: 2018-02-21T16:48:15+00:00 Subject: [ruby-core:85733] [Ruby trunk Feature#14473] Add Range#subrange? Issue #14473 has been updated by owst (Owen Stephens). +1 for this suggestion - we have a similar method in our code base, implemented approximately as follows: ~~~ ruby Range.class_exec do def subset?(other) raise ArgumentError unless other.is_a?(Range) first >= other.first && last <= other.last end end ~~~ As a `Range` represents a set of elements, should there also be `proper_subset?`, `superset?` and `proper_superset?` methods (and perhaps their operator aliases) similar to those on `Set` (http://ruby-doc.org/stdlib-2.4.2/libdoc/set/rdoc/Set.html)? ---------------------------------------- Feature #14473: Add Range#subrange? https://bugs.ruby-lang.org/issues/14473#change-70544 * 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 ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: