radash icon indicating copy to clipboard operation
radash copied to clipboard

Why is the range function max inclusive?

Open JamzOJamz opened this issue 2 years ago • 2 comments

Why is the range function in Radash max inclusive rather than max exclusive? The docs say that the function is a hat tip to the Python implementation by the same name, so why don’t they function identically? It makes it hard to iterate over an array without making the max value arr.length - 1.

Am I missing something in the docs? Any guidance would be much appreciated :)

JamzOJamz avatar Jul 25 '23 20:07 JamzOJamz

Totally agree. This unexpected API-issue does of course apply to radash.list as well. When a single parameter is passed, it is named size in the documentation, but the actual size / length of the iterator returned is one more than the number passed as size-parameter. image

torgesla avatar Oct 09 '23 08:10 torgesla

Hello @JamzOJamz and @torgesla, we'd be open to fixing this over at the Radashi fork, if either of you want to champion the effort. Of course, it's a breaking change, so please target the next branch with your PR.

aleclarson avatar Jul 23 '24 16:07 aleclarson