Skip to content

Implement to_interval for RangeInclusive, RangeFrom and RangeToInclusive#29

Merged
ptal merged 4 commits intoptal:masterfrom
George-Ogden:range
May 15, 2025
Merged

Implement to_interval for RangeInclusive, RangeFrom and RangeToInclusive#29
ptal merged 4 commits intoptal:masterfrom
George-Ogden:range

Conversation

@George-Ogden
Copy link
Contributor

@George-Ogden George-Ogden commented May 15, 2025

Implement to_interval for RangeInclusive, RangeFrom and RangeToInclusive
The ranges are inclusive to match the interval
This means that you can do the following:

(1..=5).to_interval()
(1..).to_interval()
(..=5).to_interval()

but the following fail:

(1..5).to_interval()
(..5).to_interval()

Alternative to #16

@ptal
Copy link
Owner

ptal commented May 15, 2025

Thanks.

Why not implementing (1..5) and (..5)? We can decrease by one the upper bound.

@George-Ogden
Copy link
Contributor Author

I think it is confusing:
1..5 = 1,2,3,4 so it's ambiguous whether 1..5 == [1,5] or 1..5 == [1,4]?

@ptal ptal merged commit cdd2d37 into ptal:master May 15, 2025
2 checks passed
@ptal
Copy link
Owner

ptal commented May 15, 2025

Hmm, yeah, more explicit with (1..=5) is better I guess.

@George-Ogden George-Ogden deleted the range branch May 15, 2025 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants