
Issue #19839 has been updated by sawa (Tsuyoshi Sawada). I think the analogy for `range1.overlap?(range2)` in mathematics is `interval1 ∩ interval2 ≠ ∅`, which does not hold when either `interval1` or `interval2` is an empty interval. Hence, I think that, when either `range1` or `range2` is an empty range (e.g., `2...2`, `2..1`), `range1.overlap?(range2)` should return `false`. Instead of adopting the AS #note-5 definition, ```rb def overlap?(other) other.begin == self.begin || cover?(other.begin) || other.cover?(self.begin) end ``` I propose to define it as equivalent to: ```rb def overlap?(other) return false if none? or other.none? other.begin == self.begin || cover?(other.begin) || other.cover?(self.begin) end ``` ---------------------------------------- Feature #19839: Need a method to check if two ranges overlap https://bugs.ruby-lang.org/issues/19839#change-104585 * Author: shouichi (Shouichi KAMIYA) * Status: Open * Priority: Normal ---------------------------------------- It would be convenient to have a method that checks if two ranges overlap. For example, ``` (0..10).overlap?(5..15) #=> true (0..10).overlap?(20..30) #=> false ``` -- https://bugs.ruby-lang.org/