/** * Returns the intersection of this and the given range. * If the ranges does not overlap, an empty range is returned. */ public Range intersection(Range other) { if ( ! overlaps(other)) return empty; return new Range(from.max(other.from), to.min(other.to)); }