4 ms·
I disagree, sometimes you end up building empty ranges in your code for valid reasons (as a result of math, for example). special casing a check on literals fe
by rtpg 6y ago
I disagree, sometimes you end up building empty ranges in your code for valid reasons (as a result of math, for example).
special casing a check on literals feels a bit like saying you can create an empty non-mutable vector.
- baby 6y agoI disagree, if this happens you want to document these edge-cases by failing early, this is very bad code if you don't and let the loop happen when most reviewers would have no idea if the result would be an unexpected behavior or not.
- estebank 6y agoIf I had a need for that I would write a surprised snake (0..0) instead.
- carlmr 6y agoExactly. (5..0) is almost surely a developer that expects the range 5, 4, 3, 2, 1