-
-
Notifications
You must be signed in to change notification settings - Fork 917
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
Add a generic form of Selection.Map
(requiring a more recent Go version)
#466
Comments
Hello Amelia, Thanks for the kind words! That's a great idea to move that I tried looking at recent release changes notes but the only thing I've seen so far is Will keep taking a look, happy to hear your thoughts on this too. I think the proposal itself (a generic form of Thanks, |
Selection.Map
(requiring a more recent Go version)
Heya! The stdlib introduced a lot of generic functions with the slices package, like; func IndexFunc[S ~[]E, E any](s S, f func(E) bool) int {
for i := range s {
if f(s[i]) {
return i
}
}
return -1
} However, it should be fine in this case to do as I wrote above, as the slice is not passed as a function argument. (Un)fortunately, go doesn't allow a method to have generics, without the struct having any. So the generic function would have to be introduced as a standalone function. On the flip side, this does ensure no breaking changes! |
Hey!
Yeah, sorry I should've been clearer, I meant examples of existing functions that received a generic version later on, and how they handled the naming of that generic one. But that's all moot anyway because...
So you mean that instead of having the generic
If so, I totally agree, that sounds good and introduces no breaking change concerns. Would you like to provide a PR for that? Happy to get that merged if you do, just a few things to include beyond the func itself: some helpful doc comment (probably similar to the Thanks! |
Closed by #467 |
Heya!
Was playing around with this in a project, and it has been amazing!
Noticed the Selection.Map only allowing to return a string, so wanted to change that to generics so it could return anything as currently I've used Each every time (and manually putting it in the array), while Map would be nicer to use.
As such the change;
Noticed the project is still on 1.13 when trying to add it myself, so was wondering if there are any plans to update to a newer version to allowed to usage of generics, and other later introduced features.
Thanks for the amazing project! 💕
The text was updated successfully, but these errors were encountered: