You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The omission of this feature (present in Python, for example) is deliberate
When performing arithmetic on slice indices it would be unfortunate if an erroneous negative result "just worked" as a reverse index. This leads to subtle bugs.
There are readability benefits to the status quo, also. It is clear that the Go expression s[:i] is creating a slice of s that is i bytes long. If i could be negative then the reader would need more context to understand the slice expression.
This is in keeping with Go's general philosophy of avoiding subtle syntactic tricks.
hope equivalent to python's
arr[1:-1]
. for example:we need to take arr as variable. but i want
The text was updated successfully, but these errors were encountered: