Project

General

Profile

Actions

Feature #19839

closed

Need a method to check if two ranges overlap

Added by shouichi (Shouichi Kamiya) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:114399]

Description

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

Related issues 2 (0 open2 closed)

Related to Ruby master - Feature #13933: Add Range#empty?RejectedActions
Related to Ruby master - Feature #15976: Add Array#overlap? for whether the intersection of 2 arrays is non empty?ClosedActions
Actions

Also available in: Atom PDF

Like1
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like1Like0Like0Like1Like0Like0Like0Like1Like0Like0Like0Like2Like0Like0Like0Like0Like0Like0Like0