I have a range array like:
range_array = [4830..5520, 2000..2700, 600..1335, 3660..4170]
And I check for range like:
range_array.map{|a| a.include?(3660)}.any? # Gives true as the boundary matches 3660.
I want to check for range excluding boundaries. I tried between?
, but the problem is same.
How do I achieve it with less code?
You could also check the boundaries using first
and last
:
range_array.map{|a| a.include?(3660) && a.first != 3660 && a.last != 3660}.any?