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
A major source of off-by-one errors for me has been that there is no equivalent to the Python "reverse" keyword. Forward loops are simple: for i := range s but the reverse is for i := len(s)-1; i >= 0; i--.
Please consider adding a revrange keyword or something similar.
The text was updated successfully, but these errors were encountered:
Hi,
Yep, that part of Go could get some improvement. I was thinking about something similar to Python's iterators (with __iter__ and __next__ methods), it shouldn't be that hard to do with generics (generic interfaces might be required to implement it cleanly, though, and we don't have them yet).
Reverse iteration could look like this then: for x = range reverse(s)
A major source of off-by-one errors for me has been that there is no equivalent to the Python "reverse" keyword. Forward loops are simple:
for i := range s
but the reverse isfor i := len(s)-1; i >= 0; i--
.Please consider adding a revrange keyword or something similar.
The text was updated successfully, but these errors were encountered: