Hacker News new | ask | show | jobs
by Groxx 1643 days ago
Absolutely, yes. It's downright trivial: https://gotipplay.golang.org/p/XF6wM3JF2QM

From https://itnext.io/generics-in-golang-1-18-no-need-to-write-m...

1 comments

This is a joke, right? Your trivial implementation isn't even correct.
https://gotipplay.golang.org/p/N2v8aB1tUtN

Is this one better? It does run and doesn't rely on casting (not sure why GP's source took that route, it was lossy and kind of dumb). I suspect the compilation problem was because of a change in the syntax between when that was created and today.

yeah, it's just old. the `~int | ~float32 | etc` syntax is relatively recent.