-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Discrepancy in #[](start, count)
with negative start in array-like collections
#14775
Comments
For |
I suppose we should utilize We actually use it already in Lines 452 to 456 in be46ba2
And yeah, I find the implicit clamping of |
While trying get the last 3 bytes in a slice, I noticed that
bytes[-3, 3]
failed unexpectedly. Digging a bit, I noticed that there is a discrepancy in how[](start, count)
with a negative start behaves in the different array-like collections:Array
: returnscount
entries starting from the laststart
entries (expected);Deque
: not implemented;Slice
: raises anIndex out of bounds
exception (huh?).Given that
[](index)
with a negative index is behaving the same in all these types (return item at index starting from the end), I'd expect[](count, start)
to behave the same, too.The method isn't implemented for
StaticArray
but it's likely deliberate (aka not possible). It may not make much sense forDeque
either (though possible), butSlice
was surprising.The text was updated successfully, but these errors were encountered: