(Ruby) How do you check whether a range contains a subset of another range?
If I have two ranges that overlap: x = 1..10 y = 5..15 When I say: puts x.include? y the output is: false because the two ranges only overlap partially. But if I want it to be "true" when there is partial overlap between two ranges, how would I write that? In other words I need a way to know when one range contains a subset of another range. I assume there's an elegant way to write this in Ruby but the only solutions I can think of are verbose. Be careful using this with large ranges but this is an elegant way to do it: (x.to_a & y.to_a).empty? The efficient way is to compare the limits (x