From: tarui@... Date: 2018-07-30T07:31:41+00:00 Subject: [ruby-core:88187] [Ruby trunk Feature#14473] Add Range#subrange? Issue #14473 has been updated by tarui (Masaya Tarui). Thank you for your patch owst. I reviewed it and feel the behavior below is strange. ~~~ $ ruby -e 'p (1..3.1).cover?(1...3)' true $ ruby -e 'p (1..3.1).cover?(1...4)' Traceback (most recent call last): 1: from -e:1:in `
' -e:1:in `cover?': can't iterate from Float (TypeError) ~~~ At `(a..b).cover?(c...d)` with `b < d`, is it reasonable to use `(c...d).max`(but ignore exception) for comparison with `b`? ---------------------------------------- Feature #14473: Add Range#subrange? https://bugs.ruby-lang.org/issues/14473#change-73206 * Author: greggzst (Grzegorz Jakubiak) * Status: Assigned * Priority: Normal * Assignee: tarui (Masaya Tarui) * 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) v2-0001-range.c-add-subset-superset-methods.patch (8.85 KB) v3-0001-range.c-add-subrange-superrange-methods.patch (9.24 KB) v4-0001-range.c-allow-cover-to-accept-Range-argument.patch (4.45 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: