Applied in changeset commit:git|e9b503f1bb9692eda1d1f55f62c19d861b88a0d5. ---------- [Feature #19839] Add Range#overlap? Add a method that returns true if two range overlap, otherwise false. ``` (0..10).overlap?(5..15) #=> true (0..10...shouichi (Shouichi Kamiya)
Add a method that returns true if two range overlap, otherwise false. ``` (0..10).overlap?(5..15) #=> true (0..10).overlap?(20..30) #=> false ```shouichi (Shouichi Kamiya)
Honestly, I can't give a formal reason. But I do believe it's a very basic operation. For example, postgres and boost provide such functionality. - https://www.postgresql.org/docs/15/functions-range.html - https://www.boost.org/doc/l...shouichi (Shouichi Kamiya)
Though ActiveSupport's `overlaps?` method is enough for our use-case. I think the feature is so fundamental that it should be supported by the standard library. Slightly off-topic: It might be better to add a method that returns the o...shouichi (Shouichi Kamiya)
Thank you for your feedback. > I've made several helpers for this exact same problem, as well as a `Range#merge` in the past. Yes, `Range` class can have methods such as `Range#merge` but I wanted to start small and see what happen...shouichi (Shouichi Kamiya)
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 ```shouichi (Shouichi Kamiya)