4 ms·
> Ok so my original example becomes this No, you still don't understand. Methods can't have additional type parameters, only functions. This part is not allowe
by mseepgood 6y ago
> Ok so my original example becomes this
No, you still don't understand. Methods can't have additional type parameters, only functions. This part is not allowed in your "example":
(type K, V, Q comparable)
- lsllc 6y agoThe doc says: > Generic types can have methods. The receiver type of a method must declare the same number of type parameters as are declared in the receiver type's definition. They are declared without the type keyword or any constraint. So my original example should have been: func (obj *SomeType(K, V)) Foo(key K, val V) (*OtherType(K, V), error) { ... } (hopefully this is now correct!).