3 ms·
Doesn't an interface value have both a static type and a dynamic type and in a case like x its dynamic type is "nothing"? I didn't mean that this is necessaril
by frou_dh 13y ago
Doesn't an interface value have both a static type and a dynamic type and in a case like x its dynamic type is "nothing"?
I didn't mean that this is necessarily bad, just that it seems weird for "nil" to be overloaded beyond pointers.
- shurcooL 13y agoYeah. From the Go spec: "The static type (or just type) of a variable is the type defined by its declaration. Variables of interface type also have a distinct dynamic type, which is the actual type of the value stored in the variable at run time. The dynamic type may vary during execution but is always assignable to the static type of the interface variable. For non-interface types, the dynamic type is always the static type."