3 ms·
There is no way to express an enum whose possible values are of different types. In Go code will typically "offer" concrete types, and "accept" abstract interf
by preseinger 4y ago
There is no way to express an enum whose possible values are of different types.
In Go code will typically "offer" concrete types, and "accept" abstract interfaces. Abstractions over concrete types are expressed by consumers who want to operate on those types, rather than producers who provide implementations of them. So your Shape would probably end up an interface defined by whatever consuming code wanted to treat Circles and Rectangles equivalently.