-
Notifications
You must be signed in to change notification settings - Fork 17.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
proposal: slices: add LastIndex and LastIndexFunc #63128
Comments
This makes a lot of sense, but devil's advocate, should we just tell people to do |
index doesn't make sense with iterators like it does with slices. |
I can see a reasonable argument that the slices package should have a version of all relevant functions in the bytes and strings packages. |
https://cs.opensource.google/search?q=backwards&ss=go/go:src/slices/ and according to the quoted comment, neither does https://github.com/golang/go/blob/go1.21.1/src/bytes/bytes.go#L146 |
I just ran into this. Comes up as a nice utility function when cloning the tail of a stack datastructure. I ended up rewriting it by hand. |
I propose the addition of:
which parallels the existence of:
strings.IndexXXX
strings.LastIndexXXX
bytes.IndexXXX
bytes.LastIndexXXX
In my use-case, I'm processing Unicode runes as a
[]rune
and wanted to find the last occurrence of a given rune.The text was updated successfully, but these errors were encountered: