Union and intersection of Range
s
#14488
Labels
good first issue
This is an issue suited for newcomers to become aquianted with working on the codebase.
help wanted
This issue is generally accepted and needs someone to pick it up
kind:feature
topic:stdlib:collection
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: