Re:Golang Diaries: Generics
by jallasprit on Sunday May 15, 2022 @10:03AM
(#31387632)
This is one of the first things I remarked about the Go generics implementation. It is not yet possible to use Generics on struct methods.
[ Parent
| on HN ]
No, it's not valid because there's a trivial typo probably caused by bad HTMLification. Remove the > and it's fine.
Thats a separate issue from the one being shown here. The syntax here is just invalid
Re:Golang Diaries: Generics
by Philip-J-Fry on Sunday May 15, 2022 @11:42AM
(#31388237)
You can use generics, you just can't introduce new type parameters in the method. You're free to use the type parameters defined on the type you're writing the method for.
Re:Golang Diaries: Generics
by fsdjkflsjfsoij on Sunday May 15, 2022 @10:19AM
(#31387711)
The restriction of not introducing new generic types on methods has nothing to do with why that code doesn't compile. Remove the '>' in the method signature and it works fine.