News for hackers. Stuff that matters.
Re:Go generics may use square brackets [] not parenthesis () by shirro on Tuesday July 14, 2020 @11:17PM (#23840842)
Go cheats with some built-in generic types. So you can declare a hashtable as a map of any comparable type to any other type. But yes you typically have to implement things yourself for more complex cases so that does limit the sorts of libraries that are available and the way you write programs.
Re:Go generics may use square brackets [] not parenthesis () by erik_seaberg on Tuesday July 14, 2020 @11:53PM (#23841129)
Unfortunately "comparable" is not an interface, and the default implementation (which you can't opt out of) sometimes panics.
Re:Go generics may use square brackets [] not parenthesis () by pjmlp on Wednesday July 15, 2020 @08:18AM (#23844117)
Like in everything Go, you opt out by using a clever hack like having a nameless non comparable field in the struct. Oh yeah.