Ask questionsTry out the new Go generics proposal with go-linq
Go now has a prototype of generics implementation. Here are some resources:
This potentially could give a severe performance boost to go-linq, as well as actually make this library useful.
I haven't taken a closer look at how we would do this yet. For example, we might still end up having to do some type assertions. However, it might help us redesign the package and release a v4 if the generics proposal is adopted.
Answer
questions
ahmetb
So I tried to imitate what From..Where..Select.. sort of thing would work.
Each Where/Select/... would have different type parameters:
type Array[K any] []K
func (a Array[K]) Print[V any](v V) {
for _, i := range a {
fmt.Printf("%v-%v\n",i,v)
}
}
However this is not supported by design. https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#methods-may-not-take-additional-type-arguments
Related questions
No questions were found.