6 ms·
I like it, interface{} always felt unlike anything else in go other than structs.
by nkozyra 5y ago
I like it, interface{} always felt unlike anything else in go other than structs.
- mseepgood 5y agoWhy does 'interface{}' feel unlike 'interface{String() string}' to you? Just because it doesn't have a method? You know that you can inline non-empty interfaces, too? func foo(x interface{String() string}) string { return x.String() }
- xmprt 5y agoI think people agree that those look similar however the problem is that the first is a common practice while the latter is something that no one in their right mind would do. If people replace the second with something like Stringer, then the first should be replaced too.
- nkozyra 5y agoI think you (and the other reply) are for some reason confusing my complaint as functional rather than purely syntactical.
- throwaway894345 5y ago`interface{}` is just an empty interface, and every type implements `interface{}` because every type has at least zero methods.