New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Union and intersection of Range
s
#14488
Comments
I wonder about actual use cases, yet the methods make sense. |
Using About the edge cases: Considering adjacency makes sense. |
Combined with #14487, it would be useful to have
Range
methods that, when given another range, would return a new range that contains the union or intersection of both ranges.For example:
If there is no overlap between them, I'm not 100% sure what should happen but I feel like returning
nil
makes sense.There are probably some other edge cases to work out, as well, such as:
union
be infinite in that direction?intersection
use whichever one has a finite value?1...10
and10..20
where there's nooverlap, but they are adjacent:1..20
— the union of adjacent ranges providing continuitynil
(or whatever the non-overlap result is deemed to be)?(1...10).union(1..10)
be1..10
?(1...10).intersection(1..10)
be1...10
?The text was updated successfully, but these errors were encountered: