3 ms·
The spec does say that. You can put them in the interface, but you can't use the interface. Try it: https://go.dev/play/p/9ptEd8zasML https://go.dev/play/p/9
by jrockway 4y ago
The spec does say that. You can put them in the interface, but you can't use the interface. Try it:
https://go.dev/play/p/9ptEd8zasML https://go.dev/play/p/9ptEd8zasML
- riwsky 4y agoYou can put them in the interface, and then you can use the interface as a type constraint for generics: https://go.dev/play/p/U25AzZndz-7 https://go.dev/play/p/U25AzZndz-7 If you wanted to argue that you can't use it everywhere you could use an interface before, that'd be all well and good—but your assertion > you can't actually put concrete types in interface{} definitions is just incorrect, in a way that lead you to misunderstand the article.