3 ms·
I’m still learning the language but couldn’t you use an enum containing two types to accomplish the same thing?
by merely-unlikely 4y ago
I’m still learning the language but couldn’t you use an enum containing two types to accomplish the same thing?
- nicoburns 4y agoYou can if you know all of the possible types in advance. But if you want to expose this as an interface from a library that allows users to provide their own custom implementation then you need to use traits.