blob: f1df5e70d51b8ecf7f7209b3527b8f8acfb6a98b (
plain)
| 1
2
3
4
5
6
7
8
 | class Range
  def intersection(other)
    return nil if (self.max < other.min or other.max < self.min)
    [self.min, other.min].max..[self.max, other.max].min
  end
  alias_method :&, :intersection
end
 |