18 Apr
2022
18 Apr
'22
11:31 a.m.
On Mon, Apr 18, 2022, at 14:24, John Hagen wrote:
One of the benefits that the base-class approach has over the Union approach is that the base type can define additional state and methods that the variants can implement, or can be used when referring to the base type. I see this as being more a more general and flexible ADT.
You can achieve this without `@sealed` by changing Coin -> BaseCoin, and adding `Coin = Nickle | Dime | Quarter`. `@sealed` helps avoid the need for the `Coin`/`BaseCoin` separation, and for repeating the sub-class names, but it is not essential. Ran