18 Apr
2022
18 Apr
'22
1:10 p.m.
You can achieve this without `@sealed` by changing Coin -> BaseCoin, and adding `Coin = Nickle | Dime | Quarter`.
There are some edge cases to this approach. For example, you can't put Coin in another Union and match on it because Unions do not implement isinstance: Coin = Nickle | Dime | Quarter def get_value(coin: int | Coin) -> int: match coin: case int(): return coin case Coin(): # TypeError: called match pattern must be a type return coin.value get_value(Dime())