14 ms·
> It is indeed accepted if it's there by itself, but it is rejected if you try to use the interface, which is what function f does: You can't use it as a type,
by Merovius 4y ago
> It is indeed accepted if it's there by itself, but it is rejected if you try to use the interface, which is what function f does:
You can't use it as a type, but you can use it as a constraint: https://go.dev/play/p/LnmudHIjAoQ https://go.dev/play/p/LnmudHIjAoQ
Of course, you can then not actually instantiate that function (as the type set is empty). But using concrete types in interfaces is very possible. And it's indeed why the |-operator was introduced. It allows you to use operators: https://go.dev/play/p/I3eMDBwIcHA https://go.dev/play/p/I3eMDBwIcHA