5 ms·
Oooh. My bad. Thank you! I honestly thought that wasn't possible at all. Today I learned. However, it won't work for return values, right? Because e.g. `func (
by drdaeman 4y ago
Oooh. My bad. Thank you! I honestly thought that wasn't possible at all. Today I learned.
However, it won't work for return values, right? Because e.g. `func (some something[T]) hi(b T) T` would return `any` and not whatever it was provided (`int` or `string` respectively).
https://go.dev/play/p/IYoPUQg04sg https://go.dev/play/p/IYoPUQg04sg
Also, I don't think this can work well with types narrower/fancier than `any`, e.g. I had trouble figuring out how to deal with
type IntOrString interface {
int | string
}
type something[T IntOrString] int
https://go.dev/play/p/acwjxdpHTJO https://go.dev/play/p/acwjxdpHTJO